ViroReact 3.2.3: web closes most remaining gaps and a fix for Android minified release builds
Viro on the web closes most of the gaps from the web-vs-native parity review: scene-wide events and ViroController, portals with their own backgrounds, per-face materials, animated images, full particle and physics support, post-process effects, capture on every navigator, and AR plane detection on by default. A .gltf with external files loads instead of aborting the page. On Android, a minified release build no longer crashes at launch in WorkManager's database. The web build needs @reactvision/viro-web-renderer 1.3.0. iOS and Android binaries are unchanged from 3.2.2 apart from one new header setter that only the web build calls.
Web
Everything in this section is web platform support: it is new on the web and already worked on iOS and Android. See the Web Setup Guide.
- Navigators.
projectandunprojectwork onViroARSceneNavigator,Viro3DSceneNavigatorandViroVRSceneNavigator, and scenes get the navigator assceneNavigatorand, in AR,arSceneNavigatoron the ref too.takeScreenshot,startVideoRecordingandstopVideoRecordingwork on all three:saveToCameraRolldownloads the file, andurlis an object URL you may revoke. Video carries no audio.recenterTrackingis present but does nothing, because there is no headset.ViroVRSceneNavigatorrenders in mono. Editor scenes'TAKE_PHOTOandRECORD_VIDEOfunctions use this capture. See ViroARSceneNavigator. - Events. Scene-level
onClick,onClickState,onHover,onPinch,onRotateandonFusefire; so doonTransformUpdateandignoreEventHandling.rotationPivot,scalePivotandhighAccuracyEventswork on nodes.ViroControllerreports scene-wide clicks, pinches, rotates, fuses and drags. A tap on empty space reports position[], as native does. See ViroController and Input Events. - Animation. Chains, sequences, parallels and aliases survive
registerAnimations.run={false}pauses andrun={true}resumes.onFinishfires at the end of every pass, andcolorandmaterialanimate. See Animation. - Materials, geometry and media. A model's
materialsreach it, amaterialsarray applies per face or submesh, andViroGeometrykeeps its submeshes.arShadowReceiverworks onViroQuadandViroPolygon. Primitive options work:ViroQuaduvCoordinates,ViroSpheresegments andfacesOutward,ViroPolygonholes and UVs.ViroAnimatedImageanimates, images and videos takestereoModeandplaceholderSource,ViroSkyBoxtakescolor, andViro360ImagetakesisHdr. Media supportsseekToTime,onBufferStart,onBufferEndandonUpdateTime.ViroSound.preloadSounds/unloadSounds,StreamingAudioManagerandViroImage.evictFromCachework. A.gltfwith external.binor image files is fetched and inlined; a missing file fails that model throughonErrorinstead of aborting the page. - Portals, physics, particles and lights. Each portal gets its own background, and
onPortalEnter/onPortalExitfire. Hidden bodies leave the simulation, empty Compound shapes build from the children,applyImpulsewith an offset adds torque,velocityis constant, held force and torque work, andfindCollisionsWithRayAsync,findCollisionsWithShapeAsyncanddrawBoundswork. Particle emitters take every native prop and update while running.shadowOrthographicPositionplaces a directional light. See Physics. - AR. Plane detection is on by default, as on native (set
arOptions.detectPlanestofalseto turn it off). Tracking reasons,onTrackingInitializedandonPlatformUpdatefire,anchorDetectionTypesfilters planes, and a plane can report classification, vertices andpauseUpdates.onCameraARHitTestworks, including on a virtual camera's planes. The camera feed is cropped to fill the screen instead of stretched. See ViroARScene and ViroARPlane. - Permissions.
checkPermissionsandrequestRequiredPermissionsanswercamera,microphoneandlocation. They used to resolve{}, so an app gating AR onresult.cameranever opened it.storageis always false: the web has no camera roll, and capture downloads the file instead. Asking for the microphone after aViroSoundworks on Safari. See Permission helpers. - Cameras.
ViroOrbitCameralooks at its focal point (its yaw and pitch signs were flipped). Releasing aViroCamerareturns to the default camera. Camera reads and drag work under a perspective camera component in a 3D scene; they still cannot under an orthographic projection or in live AR. - Viro Live. The web harness exports the constants, hooks, helpers and every component with a web file, and a stub called outside render warns instead of throwing.
- Editor scenes on web.
StudioSceneNavigatorwraps scenes in the native error boundary with retry, so a scene that throws no longer replaces the whole page. MANUAL plane detection mounts the plane selector. Proximity runs without an AR session. See StudioSceneNavigator.
Android
- A minified release build no longer crashes at launch with
Failed to create an instance of class androidx.work.impl.WorkDatabase. Viro uses WorkManager for VPS scan uploads, and WorkManager 2.9.1 brings Room 2.5.0, whose keep rule leaves out the constructor Room calls by reflection to create WorkManager's database. R8 removed it, so the app crashed on start inandroidx.startup.InitializationProvider. Viro's consumer rules now keep that constructor, as Room 2.6 does. Expo SDK 58 turns minification on in its Android template, so an app on it with nothing else bringing Room 2.6 or later hit this on its first release build. This can affect any minified Viro Android build, not only VR. See Integrating with Expo.
Check when upgrading
- Web: install
@reactvision/viro-web-renderer1.3.0. The peer range is now^1.3.0. Copy its wholewasm/folder. With 1.2.0 the new features stay off and a one-time warning names what is missing. - Web: plane detection is on by default, as on native. If you relied on web AR starting with no planes unless you set
arOptions.detectPlanes, set it tofalse. - Android on Expo SDK 58: build a minified release APK and open it on a device before you ship. This release removes the WorkManager crash an R8 build hit at launch.
See Upgrading to 3.2.0 for the upgrade notes, and the GitHub release.