sceneview / sceneview-android Goto Github PK
View Code? Open in Web Editor NEWSceneView is a 3D and AR Android Composable and View with Google Filament and ARCore. This is a Sceneform replacement in Kotlin
License: Apache License 2.0
SceneView is a 3D and AR Android Composable and View with Google Filament and ARCore. This is a Sceneform replacement in Kotlin
License: Apache License 2.0
The ARCore session configuration is overridden here:
This happens even if you don't set the individual parameters (in this case the default values are used). Is it an intended behavior?
I tried following the sample-ar-model-viewer
, except I want to only use the SceneView (3D only). However, I am unable to see the object, even when sceneViewer.addChild(modelNode)
is called.
I guess I'm not supposed to use an ArModelNode
but instead, ModelNode
, but I can't seem to get this working. Is it possible to post a working example using just 3D?
lateinit var sceneView: SceneView
lateinit var modelNode: ArModelNode
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
modelNode = ArModelNode(placementMode = PlacementMode.BEST_AVAILABLE).apply {
loadModel(
context = requireContext(),
coroutineScope = lifecycleScope,
glbFileLocation = "models/spiderbot.glb",
autoAnimate = true,
onLoaded = { isLoading = false })
onTrackingChanged = { _, isTracking, _ ->
actionButton.isGone = !isTracking
}
}
sceneView.addChild(modelNode)
Hey there,
Firstly thanks for your amazing work! I'm really enjoying SceneView :)
I've found a bug on render with ArSceneView when the dimensions of the view is less than full screen height, and camera permission hasn't been granted. The output is stretched like that:
When I run the app again it works fine:
It's really linked to the permission dialog. If I close the app, remove the camera permission, and run again, the bug appears again.
Add a point cloud renderer as suggested here: SceneView/sceneform-android#278
Things to consider:
gltf file failed to load
/io.github.sceneview.sample.modelviewer E/RenderableInstance: Failed to download data uri https://mdn.alipayobjects.com/rms/afts/file/https://gw.alipayobjects.com/os/H5App-BJ/1651200213519-gltf/scene.bin
android.os.NetworkOnMainThreadException
this is gltf url: https://mdn.alipayobjects.com/rms/afts/file/A*wQUKSp0j_0oAAAAAAAAAAAAAARQnAQ
I just realized in my application that the ArSceneView.renderer
is leaking so I've tried in the sample-ar-model-viewer
demo and it seems that the leak is coming from the library. I could reproduce it by simply adding the leak-canary library to the sample. I've tried to clear the ArSceneView
in the onDestroyView() of the fragment by setting it to null, but it didn't help. Here is the leak-canary heap analysis result:
HEAP ANALYSIS RESULT
====================================
1 APPLICATION LEAKS
References underlined with "~~~" are likely causes.
Learn more at https://squ.re/leaks.
1029 bytes retained by leaking objects
Signature: 99bf7c9da341a49ffdcbea9aef692c7f6673b96e
┬───
│ GC Root: System class
│
├─ android.view.inputmethod.InputMethodManager class
│ Leaking: NO (InputMethodManager↓ is not leaking and a class is never
│ leaking)
│ ↓ static InputMethodManager.sInstance
├─ android.view.inputmethod.InputMethodManager instance
│ Leaking: NO (ArSceneView↓ is not leaking and InputMethodManager is a
│ singleton)
│ ↓ InputMethodManager.mCurRootView
├─ android.view.ViewRootImpl instance
│ Leaking: NO (ArSceneView↓ is not leaking)
│ mContext instance of com.android.internal.policy.DecorContext, wrapping
│ activity io.github.sceneview.sample.armodelviewer.Activity with mDestroyed
│ = false
│ ViewRootImpl#mView is not null
│ mWindowAttributes.mTitle = "io.github.sceneview.sample.armodelviewer/io.
│ github.sceneview.sample.armodelviewer.Activity"
│ mWindowAttributes.type = 1
│ ↓ ViewRootImpl.mSurfaceChangedCallbacks
├─ java.util.ArrayList instance
│ Leaking: NO (ArSceneView↓ is not leaking)
│ ↓ ArrayList[0]
├─ io.github.sceneview.ar.ArSceneView instance
│ Leaking: NO (View attached)
│ View is part of a window view hierarchy
│ View.mAttachInfo is not null (view attached)
│ View.mID = R.id.sceneView
│ View.mWindowAttachCount = 1
│ mContext instance of io.github.sceneview.sample.armodelviewer.Activity
│ with mDestroyed = false
│ ↓ ArSceneView.renderer
│ ~~~~~~~~
├─ com.google.ar.sceneform.rendering.ArRenderer instance
│ Leaking: UNKNOWN
│ Retaining 2.1 kB in 40 objects
│ ↓ Renderer.viewAttachmentManager
│ ~~~~~~~~~~~~~~~~~~~~~
├─ com.google.ar.sceneform.rendering.ViewAttachmentManager instance
│ Leaking: UNKNOWN
│ Retaining 1.3 kB in 21 objects
│ ↓ ViewAttachmentManager.frameLayout
│ ~~~~~~~~~~~
╰→ android.widget.FrameLayout instance
Leaking: YES (ObjectWatcher was watching this because android.widget.
FrameLayout received View#onDetachedFromWindow() callback)
Retaining 1.0 kB in 16 objects
key = 974cd537-0dbb-4f32-9f2e-0a60998aa9d8
watchDurationMillis = 5934
retainedDurationMillis = 887
View not part of a window view hierarchy
View.mAttachInfo is null (view detached)
View.mWindowAttachCount = 1
mContext instance of io.github.sceneview.sample.armodelviewer.Activity
with mDestroyed = false
====================================
0 LIBRARY LEAKS
A Library Leak is a leak caused by a known bug in 3rd party code that you do
not have control over.
See https://square.github/.
io/leakcanary/fundamentals-how-leakcanary-works/#4-categorizing-leaks
====================================
0 UNREACHABLE OBJECTS
An unreachable object is still in memory but LeakCanary could not find a strong
reference path
from GC roots.
====================================
METADATA
Please include this in bug reports and Stack Overflow questions.
Build.VERSION.SDK_INT: 30
Build.MANUFACTURER: Google
LeakCanary version: 2.9.1
App process name: io.github.sceneview.sample.armodelviewer
Class count: 19745
Instance count: 175695
Primitive array count: 92345
Object array count: 22352
Thread count: 43
Heap total bytes: 77566459
Bitmap count: 2
Bitmap total bytes: 180002
Large bitmap count: 0
Large bitmap total bytes: 0
Stats: LruCache[maxSize=3000,hits=38513,misses=102077,hitRate=27%]
RandomAccess[bytes=4736305,reads=102077,travel=32772117401,range=25257049,size=8
7653658]
Analysis duration: 22954 ms
Heap dump file path: /storage/emulated/0/Download/leakcanary-io.github.
sceneview.sample.armodelviewer/2022-05-23_15-36-58_886.hprof
Heap dump timestamp: 1653309451124
Heap dump duration: Unknown
====================================
The onArFrameHitResult method is currently not called, even if the node is clicked by the user. This is really bad because many use cases include the selection of specific modelNodes for interacting with them.
It's pointed out that the bug is known but since there is no ticket (I can't find one) and this problem is the only one preventing me from migrating to this package, I thought a separate ticket is a good way to track the progress on this.
@grassydragon on discord:
If there is only one node, you can use a workaround from here: https://github.com/SceneView/sceneview-android/blob/main/samples/ar-model-viewer/src/main/java/io/github/sceneview/sample/armodelviewer/MainFragment.kt#L66
Otherwise, we need to fix picking a particular node.
Will SceneView support rendering GLB files containing KTX2 texture in the future? Or there is already a way to do so?
I used one of your sample projects to do some testing (Ar Model Viewer)
With KTX2 texture | Without KTX2 texture (PNG) |
---|---|
) | |
With KTX2 texture | Without KTX2 texture (PNG) |
:-------------------------: | :-------------------------: |
I'm sharing few resource with you guys:
KTX explanation by Khronos group : https://www.khronos.org/ktx/
I have run into an issue causing a native crash in my application, that is occuring when I navigate to my ArFragment, then quickly press back and then navigate back to the ArFragment.
I have created a minimum sample project, where it seems to sometimes need a third time navigating, but for me it would always crash with only this following message:
A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x530 in tid 15403 (nn.arsamplecode), pid 15403 (nn.arsamplecode)
With my sample project, I have found out, that in the version 0.3.0
this would not be an issue and I could navigate back and forth unlimited times, but in both 0.4.0
and 0.5.0
the app would immediately crash when pressing back from the ArFragment, which seems to have been a different issue that already got fixed now in 0.6.0
, where the new issue is occurring.
Using this minimum sample, the issue should be easily reproducible just by tapping the navigate button and quickly pressing back, and then doing both a few times in a row.
The crash seems to happen sometime between configuring and starting the session since the CheckAndWriteCurrentConfig returning OK
log happens right before, but neither onArSessionCreated
nor onArSessionFailed
get called.
This is the full native stacktrace, that I found in my Logcat when disabling the app filter, maybe someone can understand that better than I do. (Had to put it as a gist, since it was over 65536 characters and too long for this issue)
I have a Fragment which displays a SceneView and then a Dialog Fragment is displayed on top of it which contains another SceneView. The Dialog is then closed which then results in this crash.
Here is the stack trace:
FATAL EXCEPTION: main
Process: app.xxxxx.dev, PID: 5388
java.lang.IllegalStateException: no event up from DESTROYED
at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:263)
at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:307)
at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:148)
at androidx.lifecycle.LifecycleRegistry.setCurrentState(LifecycleRegistry.java:121)
at io.github.sceneview.SceneView.parentLifecycleObserver$lambda-0(SceneView.kt:77)
at io.github.sceneview.SceneView.lambda$VdyLiPAL1EzkEFreGKIq-a7OnsI(Unknown Source:0)
at io.github.sceneview.-$$Lambda$SceneView$VdyLiPAL1EzkEFreGKIq-a7OnsI.onStateChanged(Unknown Source:2)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:196)
at io.github.sceneview.SceneView.onAttachedToWindow(SceneView.kt:252)
at android.view.View.dispatchAttachedToWindow(View.java:20812)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
at android.view.ViewGroup.addViewInner(ViewGroup.java:5290)
at android.view.ViewGroup.addView(ViewGroup.java:5076)
at android.view.ViewGroup.addView(ViewGroup.java:5016)
at com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController.attachView(ViewController.java:208)
at com.reactnativenavigation.viewcontrollers.modal.ModalPresenter.dismissModal(ModalPresenter.java:100)
at com.reactnativenavigation.viewcontrollers.modal.ModalStack.dismissModal(ModalStack.java:70)
at com.reactnativenavigation.viewcontrollers.navigator.Navigator.dismissModal(Navigator.java:196)
at com.reactnativenavigation.react.NavigationModule.lambda$dismissModal$9$NavigationModule(NavigationModule.java:164)
at com.reactnativenavigation.react.-$$Lambda$NavigationModule$K6INt9hfoIC5qsY-5Qqg9HQA-Bc.run(Unknown Source:10)
at com.reactnativenavigation.react.NavigationModule.lambda$handle$13$NavigationModule(NavigationModule.java:199)
at com.reactnativenavigation.react.-$$Lambda$NavigationModule$5N1_9vuln3JXRnlJ810xNwkxdsA.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7842)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
I'm not sure what's causing this, but I'm thinking it might be the way i'm using the lifecycle?
Here is how i'm using SceneView within a FrameLayout inside of a Fragment:
class RNTExerciseViewKt(context: Context, lifecycle: Lifecycle, reactContext: ReactContext, reactNativeViewId: Int) : FrameLayout(context) {
private val sceneView = SceneView(context)
private val cameraOrbit = Node()
private var modelNode = ModelNode()
private lateinit var camera: Camera
private var currentlyPlaying: ObjectAnimator? = null
init {
this.addView(sceneView)
sceneView.addChild(modelNode)
lifecycle.coroutineScope.launchWhenCreated {
sceneView.environment = KTXLoader.loadEnvironment(
context = context,
lifecycle = lifecycle,
iblKtxFileLocation = "environments/default_environment_ibl.ktx",
skyboxKtxFileLocation = null
)
...
}
}
}
ie ,
On background I need a camera view and my 3d model node will be on the screen (as a sticky one), even I changed the camera position the node will be there , camera view will only change..!
This one I have intergrated on sceneForm, but when I moved to sceneView , its not working
pls help.?
I'm trying to get the sample model displayed in my Java code. I've got everything working in SceneForm but I'm trying to migrate to this project for the memory management improvements. What am I doing wrong here? (This is a native android component I'm bridging for use in React Native so this class is being rendered inside of a Fragment.)
Here is my code:
class RNTExerciseView extends FrameLayout {
private SceneView sceneView;
private ModelNode characterModel;
private Node cameraOrbit;
private Camera camera;
private ObjectAnimator currentlyPlaying;
public RNTExerciseView(@NonNull Context context, ReactContext reactContext, int reactNativeViewId) {
super(context);
sceneView = new SceneView(context);
sceneView.setBackgroundColor(Color.rgb(255, 255, 255));
sceneView.setTransparent(true);
sceneView.setZOrderOnTop(false);
this.addView(sceneView);
characterModel = new ModelNode();
sceneView.addChild(characterModel);
characterModel.setWorldPosition(new Float3(0, 0, -5));
characterModel.loadModelAsync(
context,
"https://sceneview.github.io/assets/models/MaterialSuite.glb",
null,
true,
true,
new Float3(0, 0, 0),
null,
instance -> {
return null;
});
}
}
How to create a fixed 3d model node in SceneView (for example, to make the model visible on the screen even if the camera is moved).
Hi,
We are planning to move from sceneform android to sceneview and we are primarily focusing on Augmented Images.
Does sceneview has a sample for augmented images ? I found some augmentedImage related code in library code.
How can I go about implementing it ? Where do I start ? Anyway, I'll try implementing it, will let you know if I hit some block somewhere.
I'm experiencing sawy edges when loading a model in the SceneView. Hardware Acceleration seems to be disabled.
The error occured on an a Galaxy Tab S8
simply added a SceneView like this
<io.github.sceneview.SceneView
android:id="@+id/sceneView"
android:layout_height="match_parent"
android:layout_width="match_parent"
/>
sceneView = findViewById(R.id.sceneView)
...
val model = ModelNode()
sceneView.addChild(model)
lifecycleScope.launchWhenCreated {
model.loadModel(
context = this@MainActivity,
glbFileLocation = "models/FiatPunto.glb",
autoAnimate = false,
autoScale = true,
centerOrigin = Position(x = 0.0f, y = 0.0f, z = 0.0f)
)
}
If I print
Log.i("SceneView", "HWaccel = " + sceneView.isHardwareAccelerated)
I recieve false
.
That's how it looks like (very prominent on the lower end of the windows):
Before moving the
PlaneVisualizer
to Kotlin let's decide what to do with theRenderable
andRenderableInstance
classes: #40
Big subject here even if I'm conviced that most of the Renderable
and RenderableInstance
with the old sfb managed can be cleaned quite quickly. Resulting in a quite simple class.
Originally posted by @ThomasGorisse in #39 (comment)
hello, when using sceneview to display an object everything works great until you leave the activity and onDestroy gets called
i cloned the project and in sceneview.kt i commented this in the override destroy
override fun onDestroy(owner: LifecycleOwner)
{
super.onDestroy(owner)
//renderer.destroyAllResources()
//camera.destroy()
//environment?.destroy()
environment = null
//mainLight?.destroy()
mainLight = null
}
after doing this everything works perfectly, if you could change this in the real git repository or find a better way to fix it that would be great, if you want me to push my version ill do that, i just dont want to accidentally break something
Deleted
Is there a way to detect the size (dimensions) of a loaded GLB file and calculate a scale factor so that the 3D model fits on the Android screen? Filament has a method called transformToUnitCube()
which "tells the model viewer to transform the root node of the scene such that it fits into a 1x1x1 cube centered at the origin".
Could we build something like that for SceneView
?
private fun loadGlb(name: String) {
val buffer = readAsset("models/${name}.glb")
modelViewer.loadModelGlb(buffer)
modelViewer.transformToUnitCube()
}
Source: https://medium.com/@philiprideout/getting-started-with-filament-on-android-d10b16f0ec67
Hello, I was trying to understand learn and understand "sceneview" usages, I already discovered how to get Augmented face in "sceneform-android" but when I try sceneview, I encountered several problems,
Here my minimal code (only MainActivity)
private lateinit var binding: ActivityMainBinding
private val facesNodes = HashMap<AugmentedFace, AugmentedFaceNode>()
private var faceModel: ModelRenderable? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
loadModels()
}
private fun loadModels() {
lifecycleScope.launchWhenCreated {
binding.sceneView.configureSession { arSession, config ->
val filter =
CameraConfigFilter(arSession).setFacingDirection(CameraConfig.FacingDirection.FRONT)
val cameraConfig = arSession.getSupportedCameraConfigs(filter)[0]
arSession.cameraConfig = cameraConfig
config.instantPlacementMode = Config.InstantPlacementMode.DISABLED
config.augmentedFaceMode = Config.AugmentedFaceMode.MESH3D
arSession.configure(config)
}
faceModel = loadModel(
context = this@MainActivity,
lifecycle = lifecycle,
glbFileLocation = "models/fox.glb",
)
binding.sceneView.onAugmentedFaceUpdate = {
val existingFaceNode = facesNodes[it]
when (it.trackingState) {
TrackingState.TRACKING ->
if (existingFaceNode == null) {
val faceNode = AugmentedFaceNode(binding.sceneView.lifecycle, it)
val modelInstance = faceNode.setFaceRegionsRenderable(faceModel)
modelInstance.isShadowCaster = false
modelInstance.isShadowReceiver = true
faceNode.faceRegionsRenderable = faceModel!!
binding.sceneView.addChild(faceNode)
facesNodes[it] = faceNode
}
TrackingState.STOPPED -> {
if (existingFaceNode != null) {
binding.sceneView.removeChild(existingFaceNode)
facesNodes.remove(it)
}
facesNodes.remove(it)
}
else -> {
facesNodes.remove(it)
}
}
}
}
}
activity_main.xml snippet as well
<io.github.sceneview.ar.ArSceneView
android:id="@+id/sceneView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
PS : I used "fox and "face" glb files from sceneform for quick testing.
If you need additional information please let me know.
Thank you.
Compile error when under Android API level 24.
Wonder to see if it is possible to allow compile under API level 24 and require run-time checking to use.
For the 3D only package that without ARCore, see if it is possible to allow lower API level.
I'd like to have an ARModelNode that can be moved and rotated using gestures.
I guess I can't use the ARModelNode directly as the TransformableNode needs a ArNode as its parent. The way to go would be this node hierachy:
This results in my model rotating around the anchor instead of rotating around itself.
Could you help me to achieve the right result?
Thanks!
Hey.
Doing the implementation we found out that ARCore whitout sceneview is able to detect vertical walls with just one color.
Like in the example by google hello_ar_java, that is working.
But with sceneview that was not the case. Changing the config from HORIZONTAL_VERTICAL or just VERTICAL in the plane finding mode, doesn't make a difference.
We know that it's possible and we see a lot of "default" implementations of ArCore doing this.
This is an issue? This will be fixed? What can we expect SceneView to do about this?
If the ViewNode
is moved to another location, it still responds to touches where it has been before.
I have been running into an issue, where my app will crash after navigation from and back to my AR Fragment multiple times.
It seems to me, that the Filament material of the plane renderer is not getting cleaned up properly when my fragment is destroyed.
Confusing to me is the fact, that it does not crash when opening it after closing just once, but usually after at least 3 and up to 6 times of navigating out and back into the fragment. Additionally, it doesn't crash instantly onCreate of my fragment, but rather after around 1-3 seconds of working normally.
E/Filament: in bool filament::FEngine::destroy(const filament::FMaterial *):810
reason: destroying material "AR Core Plane Material" but 4 instances still alive
[...]
java.lang.IllegalStateException: Object couldn't be destroyed (double destroy()?)
It seems to crash for both the "AR Core Plane Material" and the "AR Core Plane Shadow Material", as I have had either in my stacktraces. This is one of these stacktrace: https://pastebin.com/z8Bq35du
I couldn't find anything from sceneview to call onDestroy of my fragment to solve this, so I was hoping for some help here.
I'm trying to set a foot print shadow but I'm not seeing one when I try to add a FootprintSelectionVisualizer
.
Am I missing a step?
private fun onModelLoaded(modelRenderable: ModelRenderable) {
val footprintSelectionVisualizer = FootprintSelectionVisualizer().apply {
footprintRenderable = modelRenderable // this doesn't seem to do anything
}
val transformationSystem = TransformationSystem(context.resources.displayMetrics, footprintSelectionVisualizer)
val node = DragTransformableNode(1f, transformationSystem).also {
it.renderable = modelRenderable
scene.addChild(it)
it.select()
}
scene.addOnPeekTouchListener { hitTestResult: HitTestResult?, motionEvent: MotionEvent? ->
transformationSystem.onTouch(hitTestResult, motionEvent)
}
}
With the 0.4.x release the models look very glossy and dark in AR. Using LightEstimationMode.AMBIENT_INTENSITY the model looks like intended.
@ThomasGorisse Do I have to change some settings with the new Environmental HDR code?
For some 3D viewer use cases the camera angle should be restricted to a certain angle (like prevent the user to view the model from the bottom). Frameworks for iOS like SceneKit and RealityKit allow this and I think SceneView should also allow this easily.
I'd like to use SceneView in a project but without knowing what's the license it's kind of a risk. Could you state what's the license of SceneView.
I have tried sample app with my own customised .gltf 3D Model
but it is causing java.lang.OutOfMemoryError: Failed to allocate a 134217744 byte allocation with 25165824 free bytes and 124MB until OOM, target footprint 95769496, growth limit 201326592 issue while rendering it.
is it due to large size of 3D Model ? FYI my model size is 69 MB.
I am trying to face problem for adding and removing stl files from a model.
What I want to achieve is :
Add Multiple STL models in a mesh
can able to remove an STL model on selecting.
please help to update the code and mention here
What I want is referring to this app below:
https://play.google.com/store/apps/details?id=com.performance.meshview
I experienced some strange behaviour using the ModelNode.rotation
attribute.
Those values work as expected (as long as y = 0.0f
)
model.rotation = Rotation(x = 0.0f, y = 0.0f, z = 0.0f)
car facing towards me with the front
model.rotation = Rotation(x = 40.0f, y = 0.0f, z = 0.0f)
front of the car goes down
model.rotation = Rotation(x = 0.0f, y = 0.0f, z = 40.0f)
car rotates around z-axis
model.rotation = Rotation(x = 40.0f, y = 0.0f, z = 40.0f)
front of car goes down and is rotated around z-axis
Then when a rotation around y-axis is included a rotation around the relative z-axis of the element is no longer working. It seems
z values now acts as x-axis rotation value but with opposite signs of the actual x-rotation value.
model.rotation = Rotation(x = 40.0f, y = 90.0f, z = 40.0f)
only rotated around the y-axis by 90°
model.rotation = Rotation(x = 0.0f, y = 90.0f, z = 40.0f)
rotated around y-axis by 90° and front of car facing up (rotation around world's z-axis but not the model's z-axis)
This last example also meets the expectations
model.rotation = Rotation(x = 40.0f, y = 90.0f, z = 0.0f)
rotated around y-axis by 90° and front of car facing down (as expected because it's rotated around the model's x-axis)
After getting LightNode to work, I've found that adding directional lights does not work.
If you add one directional light, it overrides the scene's mainLight as generated by lightEstimationMode= LightEstimationMode.AMBIENT_INTENSITY, if you add multiple only the last one added is used.
The simple test is to add multiple directional lights with different colours and see that only the one added last actually illuminates the scene and removes the default illumination.
I ran into a new exception today that caused my app to crash, but only has happened this one time. Since I wasn't at home and not connected to Logcat, I don't quite remember all the details and only have this one final stack trace from my logfile:
2022-03-15 15:03:39.500 E/FATAL: A fatal crash caused the app to stop
java.lang.AssertionError: Unable to create RenderableInstance.
at com.google.ar.sceneform.rendering.RenderableInternalData.buildInstanceData(RenderableInternalData.java:229)
at com.google.ar.sceneform.rendering.RenderableInstance.prepareForDraw(RenderableInstance.java:488)
at com.google.ar.sceneform.rendering.Renderer.updateInstances(Renderer.java:668)
at com.google.ar.sceneform.rendering.Renderer.render(Renderer.java:314)
at io.github.sceneview.SceneView.doFrame(SceneView.kt:297)
at io.github.sceneview.ar.ArSceneView.doFrame(ArSceneView.kt:246)
at io.github.sceneview.SceneView.doFrame(SceneView.kt:291)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1350)
at android.view.Choreographer.doCallbacks(Choreographer.java:1149)
at android.view.Choreographer.doFrame(Choreographer.java:1040)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1333)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:233)
at android.app.ActivityThread.main(ActivityThread.java:8068)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
As far as I remember, I was already using my app for around 5-10 Minutes when it happened and the error (I think) occurred right when placing another 3d model, after having already placed quite a few within the same scene (~15 objects).
I was using the 0.1.0 version of sceneview when the bug happened and was hoping maybe someone had some insights as to what this could be caused by.
On a sidenote that might be related: I am not using ArModelNodes
and their loadModel function, but I am loading my 3d models in advance and holding a reference within my code to those renderables and then setting them with ArNode.setModel
. Since I have never had any issues with this, I doubt it is the cause, but I figured it could still be relevant to the exception.
Is the
topMostPlane
actually the top most here?
Yes it should
There is definetly something to do to clean this part:
Originally posted by @ThomasGorisse in #39 (comment)
I'm playing with the sample-model-viewer app and I see that touch events are being detected via the nodeGestureRecognizer
but the models don't move. It seems that the OnGestureStartedListener
s are not being added and so the touch event doesn't get propagated.
What is the proper way to ensure touch events like drag and pinch are able to rotate/scale a model in 3D only mode?
I want to be able to add multiple objects on the plane automatically based on a condition i make (walking distance, time, loop...)
I couldn't find documentation for the project and the samples projects are very basic and lacking comments.
I have been having a very strange issue in my project that occurs after resolving AR Core Cloud Anchors, where I am not entirely sure if this error is related to sceneview, but since I am unable to find the root cause of this error, I figured you might know something or have had a similar problem like this before.
So my app does not crash with any "normal" exceptions or stacktrace, but when navigating away from my AR fragment, the app will just close with the following error message that doesn't really help too much:
I/native: I0304 19:19:53.140083 16305 session_lite_c_api.cc:37] Deleting ArSession...
A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x6c00000018 in tid 25038 (Thread-20), pid 16305 (nn.arsamplecode)
While trying to find the cause, I could pinpoint it on callling session.resolveCloudAnchor()
with an existing anchor ID.
Turns out, while AR Core is still trying to resolve a cloud anchor and hasn't found it yet, it will crash when trying to navigate away from the fragment. As soon as the anchor is successfully resolved, navigating works perfectly fine again.
I created a small sample to hopefully reproduce the issue, though for that you will have to use your own Cloud Anchor API Key and an existing cloud anchor ID.
In the sample, tapping on the AR plane will call the resolveCloudAnchor
, and then simply navigating back will crash the app.
Since I really am out of approaches of how to fix this, I was hoping that maybe y'all have some experience with these kind of errors or potentially have an idea how I can solve this issue.
Thanks alot in advance
Previously when using SceneForm, I'm able to have a white background behind all the models being rendered in the scene like this:
sceneView.setBackgroundColor(Color.rgb(255, 255, 255));
sceneView.setTransparent(true);
sceneView.setZOrderOnTop(true);
Now when I do this in SceneView, all I get is a blank white view.
Would you mind doing the move from RenderableDefinittion to Filament direct mesh creation?
We just need to make sure that we aren't missing any important features that Sceneform provided for mesh creation. I actually only used the direct Filament approach.
Originally posted by @grassydragon in #39 (comment)
All problems related to Filament picking should be fixed including:
Node
that was touched from a renderable ID #96Node
#96SceneView
and Node
s #96Node
#99Node
66b5bf5How this can be done:
typealias
es for Int
IDs and extension methods as, for example, for Filament lights (https://github.com/SceneView/sceneview-android/blob/main/sceneview/src/main/kotlin/io/github/sceneview/light/Light.kt) or transforms (https://medium.com/@philiprideout/getting-started-with-filament-on-android-d10b16f0ec67). This seems to be a good approach to make Filament easier to use in Kotlin.there is the Deprecated.kt file
Link is dead, I suppose.
I am using Scence view to show 3D model in a view but its show on the top of all view Here i add my code and file
Screenshot_20220324_124156.zip
addChild(TransformableNode)?
Why doesn't it work for me?
DepathNode(context,coroutineScope = lifecycleScope,modelGlbFileLocation = "url",onModelLoaded = {}).apply{
addChild(TransformableNode(arSceneView.nodeGestureRecognizer).apply{
select()
})
}
Please give me a hand
Is it supposed to work ? The scale gesture detector works well.
Samsung S8 - Android 9
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.