Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions samples/model-viewer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,5 @@ dependencies {
implementation project(":samples:common")

// SceneView
// releaseImplementation "io.github.sceneview:sceneview:2.0.0"
// debugImplementation project(":sceneview_2_0_0")
implementation "io.github.sceneview:sceneview:2.0.0"
implementation "io.github.sceneview:sceneview:2.0.2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.commit
import io.github.sceneview.utils.doOnApplyWindowInsets
import io.github.sceneview.utils.setFullScreen
import io.github.sceneview.sample.doOnApplyWindowInsets
import io.github.sceneview.sample.setFullScreen

class Activity : AppCompatActivity(R.layout.activity) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,42 @@ import androidx.core.view.isGone
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import io.github.sceneview.SceneView
import io.github.sceneview.loaders.loadHdrIndirectLight
import io.github.sceneview.loaders.loadHdrSkybox
import io.github.sceneview.math.Position
import io.github.sceneview.math.Rotation
import io.github.sceneview.nodes.ModelNode
import io.github.sceneview.nodes.ViewNode
import io.github.sceneview.math.Scale
import io.github.sceneview.node.ModelNode
import kotlinx.coroutines.launch

class MainFragment : Fragment(R.layout.fragment_main) {

lateinit var sceneView: SceneView
lateinit var loadingView: View
private lateinit var sceneView: SceneView
private lateinit var loadingView: View

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

sceneView = view.findViewById<SceneView>(R.id.sceneView).apply {
setLifecycle(lifecycle)
}
sceneView = view.findViewById(R.id.sceneView)
loadingView = view.findViewById(R.id.loadingView)

lifecycleScope.launchWhenCreated {
viewLifecycleOwner.lifecycleScope.launch {
val hdrFile = "environments/studio_small_09_2k.hdr"
sceneView.loadHdrIndirectLight(hdrFile, specularFilter = true) {
intensity(30_000f)
}
sceneView.loadHdrSkybox(hdrFile) {
intensity(50_000f)
}

val model = sceneView.modelLoader.loadModel("models/MaterialSuite.glb")!!
val modelNode = ModelNode(sceneView, model).apply {
transform(
position = Position(z = -4.0f),
rotation = Rotation(x = 15.0f)
)
scaleToUnitsCube(2.0f)
// TODO: Fix centerOrigin
// centerOrigin(Position(x=-1.0f, y=-1.0f))
playAnimation()
sceneView.environmentLoader.loadHDREnvironment(hdrFile).apply {
sceneView.indirectLight = this?.indirectLight
sceneView.skybox = this?.skybox
}
sceneView.addChildNode(modelNode)

val viewNode = ViewNode(
sceneView = sceneView,
viewResourceId = R.layout.view_node_layout
).apply {
transform(
position = Position(z = -4f),
rotation = Rotation()
)
sceneView.cameraNode.apply {
position = Position(z = 4.0f)
}
sceneView.addChildNode(viewNode)

val modelFile = "models/MaterialSuite.glb"
val modelInstance = sceneView.modelLoader.createModelInstance(modelFile)

val modelNode = ModelNode(
modelInstance = modelInstance,
scaleToUnits = 2.0f,
)
modelNode.scale = Scale(0.05f)
Copy link
Contributor Author

@waliahimanshu waliahimanshu Feb 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

model is too big - without scaling its not visible scalling down!

sceneView.addChildNode(modelNode)
loadingView.isGone = true
}
}
Expand Down
2 changes: 0 additions & 2 deletions samples/model-viewer/src/main/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:background="@drawable/info_background"
tools:context="io.github.sceneview.sample.modelviewer.Activity">

<ImageView
android:id="@+id/imageView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:alpha="0.5"
android:src="@drawable/logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
Expand Down