@needle-tools/engine 2.65.2-pre → 2.67.0-pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/dist/needle-engine.js +34490 -26304
- package/dist/needle-engine.umd.cjs +748 -303
- package/lib/engine/api.d.ts +4 -0
- package/lib/engine/api.js +10 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/codegen/register_types.js +23 -7
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/debug/debug_overlay.js +11 -2
- package/lib/engine/debug/debug_overlay.js.map +1 -1
- package/lib/engine/engine_addressables.js +4 -4
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_assetdatabase.d.ts +17 -51
- package/lib/engine/engine_assetdatabase.js +252 -126
- package/lib/engine/engine_assetdatabase.js.map +1 -1
- package/lib/engine/engine_components.js +13 -1
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_components_internal.d.ts +8 -0
- package/lib/engine/engine_components_internal.js +29 -0
- package/lib/engine/engine_components_internal.js.map +1 -0
- package/lib/engine/engine_constants.d.ts +1 -0
- package/lib/engine/engine_constants.js +1 -0
- package/lib/engine/engine_constants.js.map +1 -1
- package/lib/engine/engine_context_registry.d.ts +2 -0
- package/lib/engine/engine_context_registry.js +6 -0
- package/lib/engine/engine_context_registry.js.map +1 -1
- package/lib/engine/engine_editor-sync.d.ts +9 -0
- package/lib/engine/engine_editor-sync.js +8 -0
- package/lib/engine/engine_editor-sync.js.map +1 -0
- package/lib/engine/engine_element.d.ts +1 -0
- package/lib/engine/engine_element.js +4 -1
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_element_loading.d.ts +3 -2
- package/lib/engine/engine_element_loading.js +19 -15
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_gameobject.js +21 -23
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_gizmos.js +3 -1
- package/lib/engine/engine_gizmos.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.d.ts +2 -3
- package/lib/engine/engine_gltf_builtin_components.js +23 -6
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +3 -1
- package/lib/engine/engine_networking.js +10 -8
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking_auto.d.ts +1 -0
- package/lib/engine/engine_networking_auto.js +42 -9
- package/lib/engine/engine_networking_auto.js.map +1 -1
- package/lib/engine/engine_patcher.d.ts +8 -0
- package/lib/engine/engine_patcher.js +98 -0
- package/lib/engine/engine_patcher.js.map +1 -0
- package/lib/engine/engine_physics.d.ts +34 -2
- package/lib/engine/engine_physics.js +110 -11
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_scenetools.js +0 -1
- package/lib/engine/engine_scenetools.js.map +1 -1
- package/lib/engine/engine_serialization_core.js +4 -0
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_setup.d.ts +1 -1
- package/lib/engine/engine_setup.js +12 -5
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_texture.d.ts +6 -1
- package/lib/engine/engine_texture.js +39 -1
- package/lib/engine/engine_texture.js.map +1 -1
- package/lib/engine/engine_types.d.ts +4 -0
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_utils.js +3 -2
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_progressive.d.ts +0 -1
- package/lib/engine/extensions/NEEDLE_progressive.js +24 -26
- package/lib/engine/extensions/NEEDLE_progressive.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_render_objects.js +9 -0
- package/lib/engine/extensions/NEEDLE_render_objects.js.map +1 -1
- package/lib/engine/extensions/extensions.d.ts +4 -1
- package/lib/engine/extensions/extensions.js +16 -0
- package/lib/engine/extensions/extensions.js.map +1 -1
- package/lib/engine/extensions/usage_tracker.d.ts +12 -0
- package/lib/engine/extensions/usage_tracker.js +59 -0
- package/lib/engine/extensions/usage_tracker.js.map +1 -0
- package/lib/engine-components/Animator.js +0 -1
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AnimatorController.js +4 -0
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/AudioSource.js +2 -1
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +6 -0
- package/lib/engine-components/Camera.js +70 -31
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CharacterController.d.ts +1 -0
- package/lib/engine-components/CharacterController.js +14 -9
- package/lib/engine-components/CharacterController.js.map +1 -1
- package/lib/engine-components/Collider.js +14 -1
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +52 -0
- package/lib/engine-components/Component.js +55 -14
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/Networking.js +19 -0
- package/lib/engine-components/Networking.js.map +1 -1
- package/lib/engine-components/OrbitControls.d.ts +2 -0
- package/lib/engine-components/OrbitControls.js +9 -0
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/ParticleSystem.d.ts +5 -1
- package/lib/engine-components/ParticleSystem.js +52 -7
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/ParticleSystemModules.d.ts +2 -0
- package/lib/engine-components/ParticleSystemModules.js +26 -0
- package/lib/engine-components/ParticleSystemModules.js.map +1 -1
- package/lib/engine-components/ParticleSystemSubEmitter.js +5 -2
- package/lib/engine-components/ParticleSystemSubEmitter.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.js +18 -6
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +1 -1
- package/lib/engine-components/Renderer.js +33 -11
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/ScreenCapture.js +3 -3
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/Skybox.js +2 -0
- package/lib/engine-components/Skybox.js.map +1 -1
- package/lib/engine-components/SmoothFollow.js +1 -2
- package/lib/engine-components/SmoothFollow.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.js +3 -3
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SyncedCamera.js +1 -1
- package/lib/engine-components/SyncedCamera.js.map +1 -1
- package/lib/engine-components/SyncedTransform.js +2 -2
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/TestRunner.js +1 -1
- package/lib/engine-components/TestRunner.js.map +1 -1
- package/lib/engine-components/WebARCameraBackground.d.ts +19 -0
- package/lib/engine-components/WebARCameraBackground.js +185 -0
- package/lib/engine-components/WebARCameraBackground.js.map +1 -0
- package/lib/engine-components/WebARSessionRoot.js +3 -2
- package/lib/engine-components/WebARSessionRoot.js.map +1 -1
- package/lib/engine-components/WebXR.d.ts +4 -0
- package/lib/engine-components/WebXR.js +11 -8
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/WebXRAvatar.js +1 -0
- package/lib/engine-components/WebXRAvatar.js.map +1 -1
- package/lib/engine-components/WebXRGrabRendering.js +2 -2
- package/lib/engine-components/WebXRGrabRendering.js.map +1 -1
- package/lib/engine-components/WebXRSync.js +2 -2
- package/lib/engine-components/WebXRSync.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +14 -6
- package/lib/engine-components/codegen/components.js +14 -6
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/js-extensions/Object3D.js +4 -1
- package/lib/engine-components/js-extensions/Object3D.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Antialiasing.d.ts +13 -0
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js +46 -0
- package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/Bloom.d.ts +12 -0
- package/lib/engine-components/postprocessing/Effects/Bloom.js +76 -0
- package/lib/engine-components/postprocessing/Effects/Bloom.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.d.ts +8 -0
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js +39 -0
- package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +12 -0
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +96 -0
- package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/DepthOfField.d.ts +21 -0
- package/lib/engine-components/postprocessing/Effects/DepthOfField.js +87 -0
- package/lib/engine-components/postprocessing/Effects/DepthOfField.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/Pixelation.d.ts +7 -0
- package/lib/engine-components/postprocessing/Effects/Pixelation.js +30 -0
- package/lib/engine-components/postprocessing/Effects/Pixelation.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.d.ts +11 -0
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js +70 -0
- package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +16 -0
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js +52 -0
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js.map +1 -0
- package/lib/engine-components/postprocessing/Effects/Vignette.d.ts +11 -0
- package/lib/engine-components/postprocessing/Effects/Vignette.js +57 -0
- package/lib/engine-components/postprocessing/Effects/Vignette.js.map +1 -0
- package/lib/engine-components/postprocessing/PostProcessingEffect.d.ts +29 -0
- package/lib/engine-components/postprocessing/PostProcessingEffect.js +89 -0
- package/lib/engine-components/postprocessing/PostProcessingEffect.js.map +1 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +13 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +119 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -0
- package/lib/engine-components/postprocessing/Volume.d.ts +23 -0
- package/lib/engine-components/postprocessing/Volume.js +176 -0
- package/lib/engine-components/postprocessing/Volume.js.map +1 -0
- package/lib/engine-components/postprocessing/VolumeParameter.d.ts +21 -0
- package/lib/engine-components/postprocessing/VolumeParameter.js +75 -0
- package/lib/engine-components/postprocessing/VolumeParameter.js.map +1 -0
- package/lib/engine-components/postprocessing/VolumeProfile.d.ts +7 -0
- package/lib/engine-components/postprocessing/VolumeProfile.js +42 -0
- package/lib/engine-components/postprocessing/VolumeProfile.js.map +1 -0
- package/lib/engine-components/timeline/TimelineTracks.js +14 -15
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/ui/Text.js +28 -170
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components-experimental/networking/PlayerSync.d.ts +18 -0
- package/lib/engine-components-experimental/networking/PlayerSync.js +62 -8
- package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -1
- package/lib/include/three/ARButton.d.ts +1 -1
- package/lib/include/three/ARButton.js +11 -19
- package/lib/include/three/ARButton.js.map +1 -1
- package/lib/include/three/VRButton.js +1 -4
- package/lib/include/three/VRButton.js.map +1 -1
- package/package.json +3 -2
- package/plugins/vite/drop-client.js +77 -0
- package/plugins/vite/drop.js +81 -0
- package/plugins/vite/editor-connection.js +121 -0
- package/plugins/vite/index.js +9 -4
- package/plugins/vite/meta.js +3 -0
- package/plugins/vite/poster-client.js +6 -4
- package/src/engine/api.ts +30 -1
- package/src/engine/codegen/register_types.js +25 -9
- package/src/engine/debug/debug_overlay.ts +11 -2
- package/src/engine/engine_addressables.ts +4 -4
- package/src/engine/engine_assetdatabase.ts +291 -184
- package/src/engine/engine_components.ts +20 -1
- package/src/engine/engine_components_internal.ts +30 -0
- package/src/engine/engine_constants.ts +4 -1
- package/src/engine/engine_context_registry.ts +7 -0
- package/src/engine/engine_editor-sync.ts +21 -0
- package/src/engine/engine_element.ts +8 -1
- package/src/engine/engine_element_loading.ts +19 -15
- package/src/engine/engine_gameobject.ts +579 -583
- package/src/engine/engine_gizmos.ts +3 -2
- package/src/engine/engine_gltf_builtin_components.ts +30 -15
- package/src/engine/engine_networking.ts +10 -8
- package/src/engine/engine_networking_auto.ts +48 -11
- package/src/engine/engine_patcher.ts +113 -0
- package/src/engine/engine_physics.ts +128 -12
- package/src/engine/engine_scenetools.ts +0 -1
- package/src/engine/engine_serialization_core.ts +6 -0
- package/src/engine/engine_setup.ts +15 -5
- package/src/engine/engine_texture.ts +54 -5
- package/src/engine/engine_types.ts +6 -1
- package/src/engine/engine_utils.ts +6 -5
- package/src/engine/extensions/NEEDLE_progressive.ts +32 -32
- package/src/engine/extensions/NEEDLE_render_objects.ts +10 -1
- package/src/engine/extensions/extensions.ts +22 -1
- package/src/engine/extensions/usage_tracker.ts +91 -0
- package/src/engine-components/Animator.ts +0 -1
- package/src/engine-components/AnimatorController.ts +2 -0
- package/src/engine-components/AudioSource.ts +1 -1
- package/src/engine-components/Camera.ts +77 -37
- package/src/engine-components/CharacterController.ts +12 -9
- package/src/engine-components/Collider.ts +16 -2
- package/src/engine-components/Component.ts +74 -30
- package/src/engine-components/Networking.ts +9 -1
- package/src/engine-components/OrbitControls.ts +11 -2
- package/src/engine-components/ParticleSystem.ts +54 -10
- package/src/engine-components/ParticleSystemModules.ts +28 -1
- package/src/engine-components/ParticleSystemSubEmitter.ts +5 -3
- package/src/engine-components/ReflectionProbe.ts +17 -7
- package/src/engine-components/Renderer.ts +36 -16
- package/src/engine-components/ScreenCapture.ts +3 -3
- package/src/engine-components/Skybox.ts +2 -0
- package/src/engine-components/SmoothFollow.ts +4 -4
- package/src/engine-components/SpectatorCamera.ts +3 -3
- package/src/engine-components/SyncedCamera.ts +1 -1
- package/src/engine-components/SyncedTransform.ts +2 -2
- package/src/engine-components/TestRunner.ts +1 -1
- package/src/engine-components/WebARCameraBackground.ts +215 -0
- package/src/engine-components/WebARSessionRoot.ts +3 -2
- package/src/engine-components/WebXR.ts +12 -8
- package/src/engine-components/WebXRAvatar.ts +1 -1
- package/src/engine-components/WebXRGrabRendering.ts +2 -2
- package/src/engine-components/WebXRSync.ts +2 -2
- package/src/engine-components/codegen/components.ts +14 -6
- package/src/engine-components/js-extensions/Object3D.ts +6 -1
- package/src/engine-components/postprocessing/Effects/Antialiasing.ts +52 -0
- package/src/engine-components/postprocessing/Effects/Bloom.ts +75 -0
- package/src/engine-components/postprocessing/Effects/ChromaticAberration.ts +36 -0
- package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +114 -0
- package/src/engine-components/postprocessing/Effects/DepthOfField.ts +90 -0
- package/src/engine-components/postprocessing/Effects/Pixelation.ts +28 -0
- package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.ts +71 -0
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +55 -0
- package/src/engine-components/postprocessing/Effects/Vignette.ts +55 -0
- package/src/engine-components/postprocessing/PostProcessingEffect.ts +112 -0
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +148 -0
- package/src/engine-components/postprocessing/Volume.ts +194 -0
- package/src/engine-components/postprocessing/VolumeParameter.ts +85 -0
- package/src/engine-components/postprocessing/VolumeProfile.ts +40 -0
- package/src/engine-components/timeline/TimelineTracks.ts +16 -17
- package/src/engine-components/ui/Text.ts +37 -174
- package/src/engine-components-experimental/networking/PlayerSync.ts +69 -8
- package/src/include/three/ARButton.js +13 -24
- package/src/include/three/VRButton.js +1 -7
- package/lib/engine-components/Volume.d.ts +0 -34
- package/lib/engine-components/Volume.js +0 -140
- package/lib/engine-components/Volume.js.map +0 -1
- package/src/engine-components/Volume.ts +0 -141
|
@@ -90,6 +90,8 @@ class SharedMaterialArray implements ISharedMaterials {
|
|
|
90
90
|
if (!target) continue;
|
|
91
91
|
const mat = target.material as Material;
|
|
92
92
|
if (!mat) continue;
|
|
93
|
+
// set the shadow side to the same as the side of the material, three flips this for some reason
|
|
94
|
+
mat.shadowSide = mat.side;
|
|
93
95
|
for (let k = 0; k < originalMaterials.length; k++) {
|
|
94
96
|
const orig = originalMaterials[k];
|
|
95
97
|
if (!orig) {
|
|
@@ -110,7 +112,7 @@ class SharedMaterialArray implements ISharedMaterials {
|
|
|
110
112
|
this._indexMap = indexMap;
|
|
111
113
|
const warningMessage = `Renderer ${renderer.name} was initialized with missing materials - this may lead to unexpected behaviour when trying to access sharedMaterials by index.`;
|
|
112
114
|
console.warn(warningMessage);
|
|
113
|
-
if(isLocalNetwork()) showBalloonWarning("Found renderer with missing materials: please check the console for details.");
|
|
115
|
+
if (isLocalNetwork()) showBalloonWarning("Found renderer with missing materials: please check the console for details.");
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
// this lets us override the javascript indexer, only works in ES6 tho
|
|
@@ -243,18 +245,37 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
243
245
|
}
|
|
244
246
|
|
|
245
247
|
private _sharedMaterials!: SharedMaterialArray;
|
|
246
|
-
private _originalMaterials
|
|
248
|
+
private _originalMaterials?: Material[];
|
|
247
249
|
|
|
248
250
|
// this is just available during deserialization
|
|
249
251
|
private set sharedMaterials(_val: Array<Material | null>) {
|
|
250
252
|
// TODO: elements in the array might be missing at the moment which leads to problems if an index is serialized
|
|
251
|
-
this._originalMaterials
|
|
253
|
+
if (!this._originalMaterials) {
|
|
254
|
+
this._originalMaterials = _val as Material[];
|
|
255
|
+
}
|
|
256
|
+
else if (_val) {
|
|
257
|
+
let didWarn = false;
|
|
258
|
+
for (let i = 0; i < this._sharedMaterials.length; i++) {
|
|
259
|
+
const mat = i < _val.length ? _val[i] : null;
|
|
260
|
+
if (mat && mat instanceof Material) {
|
|
261
|
+
this.sharedMaterials[i] = mat as Material;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
if (!didWarn) {
|
|
265
|
+
didWarn = true;
|
|
266
|
+
console.warn("Can not assign null as material: " + this.name, mat);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
252
271
|
}
|
|
253
272
|
|
|
254
273
|
//@ts-ignore
|
|
255
274
|
get sharedMaterials(): SharedMaterialArray {
|
|
256
|
-
if (!this._sharedMaterials || !this._sharedMaterials.is(this))
|
|
275
|
+
if (!this._sharedMaterials || !this._sharedMaterials.is(this)) {
|
|
276
|
+
if (!this._originalMaterials) this._originalMaterials = [];
|
|
257
277
|
this._sharedMaterials = new SharedMaterialArray(this, this._originalMaterials);
|
|
278
|
+
}
|
|
258
279
|
return this._sharedMaterials!;
|
|
259
280
|
}
|
|
260
281
|
|
|
@@ -503,7 +524,7 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
503
524
|
// console.log(this.name, this.gameObject.matrixWorldNeedsUpdate);
|
|
504
525
|
const needsUpdate: boolean = this.gameObject[NEED_UPDATE_INSTANCE_KEY] === true;// || this.gameObject.matrixWorldNeedsUpdate;
|
|
505
526
|
if (needsUpdate) {
|
|
506
|
-
if(debugInstancing)
|
|
527
|
+
if (debugInstancing)
|
|
507
528
|
console.log("UPDATE INSTANCED MATRICES", this.context.time.frame);
|
|
508
529
|
this.gameObject[NEED_UPDATE_INSTANCE_KEY] = false;
|
|
509
530
|
const remove = false;// Math.random() < .01;
|
|
@@ -607,8 +628,6 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
607
628
|
loadProgressiveTextures(material: THREE.Material) {
|
|
608
629
|
// progressive load before rendering so we only load textures for visible materials
|
|
609
630
|
if (!suppressProgressiveLoading && material) {
|
|
610
|
-
if (debugProgressiveLoading && material["_didRequestTextureLOD"] === undefined)
|
|
611
|
-
console.warn("Progressive?", this)
|
|
612
631
|
|
|
613
632
|
if (material["_didRequestTextureLOD"] === undefined && this.allowProgressiveLoading) {
|
|
614
633
|
material["_didRequestTextureLOD"] = 0;
|
|
@@ -712,7 +731,7 @@ class InstancingHandler {
|
|
|
712
731
|
|
|
713
732
|
public objs: InstancedMeshRenderer[] = [];
|
|
714
733
|
|
|
715
|
-
public setup(renderer:Renderer, obj: THREE.Object3D, context: Context, handlesArray: InstanceHandle[] | null, args: InstancingSetupArgs, level: number = 0)
|
|
734
|
+
public setup(renderer: Renderer, obj: THREE.Object3D, context: Context, handlesArray: InstanceHandle[] | null, args: InstancingSetupArgs, level: number = 0)
|
|
716
735
|
: InstanceHandle[] | null {
|
|
717
736
|
|
|
718
737
|
const res = this.tryCreateOrAddInstance(obj, context, args);
|
|
@@ -729,6 +748,14 @@ class InstancingHandler {
|
|
|
729
748
|
handlesArray = this.setup(renderer, ch, context, handlesArray, args, nextLevel);
|
|
730
749
|
}
|
|
731
750
|
}
|
|
751
|
+
|
|
752
|
+
if (level === 0) {
|
|
753
|
+
// For multi material objects we only want to track the root object's matrix
|
|
754
|
+
if (args.useMatrixWorldAutoUpdate && handlesArray && handlesArray.length >= 0) {
|
|
755
|
+
this.autoUpdateInstanceMatrix(obj);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
732
759
|
return handlesArray;
|
|
733
760
|
}
|
|
734
761
|
|
|
@@ -755,8 +782,6 @@ class InstancingHandler {
|
|
|
755
782
|
if (i.isFull()) continue;
|
|
756
783
|
if (i.geo === geo && i.material === mat) {
|
|
757
784
|
const handle = i.addInstance(mesh);
|
|
758
|
-
if (args.useMatrixWorldAutoUpdate && handle)
|
|
759
|
-
this.autoUpdateInstanceMatrix(mesh, i, handle);
|
|
760
785
|
return handle;
|
|
761
786
|
}
|
|
762
787
|
}
|
|
@@ -764,17 +789,14 @@ class InstancingHandler {
|
|
|
764
789
|
const i = new InstancedMeshRenderer(obj.name, geo, mat, 200, context);
|
|
765
790
|
this.objs.push(i);
|
|
766
791
|
const handle = i.addInstance(mesh);
|
|
767
|
-
if (args.useMatrixWorldAutoUpdate && handle)
|
|
768
|
-
this.autoUpdateInstanceMatrix(mesh, i, handle);
|
|
769
792
|
return handle;
|
|
770
793
|
}
|
|
771
794
|
return null;
|
|
772
795
|
}
|
|
773
796
|
|
|
774
|
-
private autoUpdateInstanceMatrix(obj: Object3D
|
|
797
|
+
private autoUpdateInstanceMatrix(obj: Object3D) {
|
|
775
798
|
const original = obj.matrixWorld["multiplyMatrices"].bind(obj.matrixWorld);
|
|
776
799
|
let previousMatrix: THREE.Matrix4 = obj.matrixWorld.clone();
|
|
777
|
-
|
|
778
800
|
const matrixChangeWrapper = (a: Matrix4, b: Matrix4) => {
|
|
779
801
|
const newMatrixWorld = original(a, b);
|
|
780
802
|
// console.warn("MULT", obj.matrixWorldNeedsUpdate);
|
|
@@ -786,7 +808,6 @@ class InstancingHandler {
|
|
|
786
808
|
return newMatrixWorld;
|
|
787
809
|
};
|
|
788
810
|
obj.matrixWorld["multiplyMatrices"] = matrixChangeWrapper;
|
|
789
|
-
|
|
790
811
|
// wrap matrixWorldNeedsUpdate
|
|
791
812
|
// let originalMatrixWorldNeedsUpdate = obj.matrixWorldNeedsUpdate;
|
|
792
813
|
// Object.defineProperty(obj, "matrixWorldNeedsUpdate", {
|
|
@@ -798,7 +819,6 @@ class InstancingHandler {
|
|
|
798
819
|
// originalMatrixWorldNeedsUpdate = value;
|
|
799
820
|
// }
|
|
800
821
|
// });
|
|
801
|
-
|
|
802
822
|
}
|
|
803
823
|
}
|
|
804
824
|
const instancing: InstancingHandler = new InstancingHandler();
|
|
@@ -409,9 +409,9 @@ class PeerHandle extends EventDispatcher {
|
|
|
409
409
|
disable() {
|
|
410
410
|
if (!this._enabled) return;
|
|
411
411
|
this._enabled = false;
|
|
412
|
-
this.context.connection.
|
|
413
|
-
this.context.connection.
|
|
414
|
-
this.context.connection.
|
|
412
|
+
this.context.connection.stopListen(RoomEvents.JoinedRoom, this.onConnectRoomFn);
|
|
413
|
+
this.context.connection.stopListen(RoomEvents.UserJoinedRoom, this.onUserJoinedOrLeftRoomFn);
|
|
414
|
+
this.context.connection.stopListen(RoomEvents.UserLeftRoom, this.onUserJoinedOrLeftRoomFn);
|
|
415
415
|
this.unsubscribePeerEvents();
|
|
416
416
|
}
|
|
417
417
|
|
|
@@ -43,6 +43,8 @@ export class RemoteSkybox extends Behaviour {
|
|
|
43
43
|
this._prevLoadedEnvironment = undefined;
|
|
44
44
|
}
|
|
45
45
|
this.unregisterDropEvents();
|
|
46
|
+
// Re-apply the skybox/background settings of the main camera
|
|
47
|
+
this.context.mainCameraComponent?.applyClearFlags();
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
async setSkybox(url: string | undefined | null) {
|
|
@@ -20,15 +20,11 @@ export class SmoothFollow extends Behaviour {
|
|
|
20
20
|
@serializable()
|
|
21
21
|
positionAxes : Axes = Axes.All;
|
|
22
22
|
|
|
23
|
-
// @serializable()
|
|
24
|
-
// rotationAxes : Axes = Axes.All;
|
|
25
|
-
|
|
26
23
|
flipForward: boolean = false;
|
|
27
24
|
|
|
28
25
|
private static _invertForward: THREE.Quaternion = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI);
|
|
29
26
|
private _firstUpdate = true;
|
|
30
27
|
|
|
31
|
-
|
|
32
28
|
onBeforeRender(): void {
|
|
33
29
|
this.updateNow(false);
|
|
34
30
|
}
|
|
@@ -39,9 +35,13 @@ export class SmoothFollow extends Behaviour {
|
|
|
39
35
|
const wp = getWorldPosition(this.target);
|
|
40
36
|
const fpos = this._firstUpdate || hard ? 1 : Mathf.clamp01(this.context.time.deltaTime * this.followFactor);
|
|
41
37
|
const currentPosition = this.worldPosition;
|
|
38
|
+
|
|
42
39
|
if(this.positionAxes & Axes.X) currentPosition.x = Mathf.lerp(currentPosition.x, wp.x, fpos);
|
|
43
40
|
if(this.positionAxes & Axes.Y) currentPosition.y = Mathf.lerp(currentPosition.y, wp.y, fpos);
|
|
44
41
|
if(this.positionAxes & Axes.Z) currentPosition.z = Mathf.lerp(currentPosition.z, wp.z, fpos);
|
|
42
|
+
|
|
43
|
+
// TODO lerp distance from target as well
|
|
44
|
+
|
|
45
45
|
this.worldPosition = currentPosition;
|
|
46
46
|
}
|
|
47
47
|
if (this.rotateFactor > 0) {
|
|
@@ -562,9 +562,9 @@ class SpectatorCamNetworking {
|
|
|
562
562
|
}
|
|
563
563
|
|
|
564
564
|
destroy() {
|
|
565
|
-
this.context.connection.
|
|
566
|
-
this.context.connection.
|
|
567
|
-
this.context.connection.
|
|
565
|
+
this.context.connection.stopListen("spectator-follower-changed", this._followerEventMethod);
|
|
566
|
+
this.context.connection.stopListen("spectator-request-follow", this._requestFollowMethod);
|
|
567
|
+
this.context.connection.stopListen(RoomEvents.JoinedRoom, this._joinedRoomMethod);
|
|
568
568
|
}
|
|
569
569
|
|
|
570
570
|
onSpectatedObjectChanged(target: PlayerView | undefined, _prevId?: string) {
|
|
@@ -102,7 +102,7 @@ export class SyncedCamera extends Behaviour {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
onEnable(): void {
|
|
105
|
-
this._receiveCallback = this.context.connection.
|
|
105
|
+
this._receiveCallback = this.context.connection.beginListenBinary(SyncedCameraModelIdentifier, this.onReceivedRemoteCameraInfoBin.bind(this));
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
onDisable(): void {
|
|
@@ -105,7 +105,7 @@ export class SyncedTransform extends Behaviour {
|
|
|
105
105
|
this.joinedRoomCallback = this.tryGetLastState.bind(this);
|
|
106
106
|
this.context.connection.beginListen(RoomEvents.JoinedRoom, this.joinedRoomCallback);
|
|
107
107
|
this.receivedDataCallback = this.onReceivedData.bind(this);
|
|
108
|
-
this.context.connection.
|
|
108
|
+
this.context.connection.beginListenBinary(SyncedTransformIdentifier, this.receivedDataCallback);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
onDestroy(): void {
|
|
@@ -113,7 +113,7 @@ export class SyncedTransform extends Behaviour {
|
|
|
113
113
|
if (this.syncDestroy)
|
|
114
114
|
sendDestroyed(this.guid, this.context.connection);
|
|
115
115
|
this._model = null;
|
|
116
|
-
this.context.connection.
|
|
116
|
+
this.context.connection.stopListen(RoomEvents.JoinedRoom, this.joinedRoomCallback);
|
|
117
117
|
this.context.connection.stopListenBinary(SyncedTransformIdentifier, this.receivedDataCallback);
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -21,7 +21,7 @@ export class TestSimulateUserData extends Behaviour {
|
|
|
21
21
|
|
|
22
22
|
awake(): void {
|
|
23
23
|
if (this.useFlatbuffers) {
|
|
24
|
-
this.context.connection.
|
|
24
|
+
this.context.connection.beginListenBinary(SyncedTransformIdentifier, (_mod: SyncedTransformModel) => {
|
|
25
25
|
// console.log("Received transform");
|
|
26
26
|
// const sc = SyncedTransformModel.getRootAsSyncedTransformModel(bin);
|
|
27
27
|
// console.log(mod.guid());
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { Behaviour } from "./Component";
|
|
2
|
+
import { serializable } from "../engine/engine_serialization_decorator";
|
|
3
|
+
import { RGBAColor } from "../engine-components/js-extensions/RGBAColor"
|
|
4
|
+
import { WebXR } from "../engine-components/WebXR";
|
|
5
|
+
import {
|
|
6
|
+
Camera as ThreeCamera,
|
|
7
|
+
Scene,
|
|
8
|
+
Texture,
|
|
9
|
+
Mesh, MeshBasicMaterial,
|
|
10
|
+
UniformsUtils,
|
|
11
|
+
PlaneGeometry,
|
|
12
|
+
ShaderLib,
|
|
13
|
+
ShaderMaterial,
|
|
14
|
+
DoubleSide
|
|
15
|
+
} from "three";
|
|
16
|
+
|
|
17
|
+
export class WebARCameraBackground extends Behaviour {
|
|
18
|
+
|
|
19
|
+
awake(): void {
|
|
20
|
+
WebXR.OptionalFeatures_AR.push('camera-access');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@serializable()
|
|
24
|
+
public backgroundTint: RGBAColor = new RGBAColor(1,1,1,1);
|
|
25
|
+
|
|
26
|
+
public get background() {
|
|
27
|
+
return this.backgroundPlane;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private _preRender;
|
|
31
|
+
|
|
32
|
+
onEnable(): void {
|
|
33
|
+
this._preRender = this.preRender.bind(this);
|
|
34
|
+
this.context.pre_render_callbacks.push(this._preRender);
|
|
35
|
+
|
|
36
|
+
if (this.backgroundPlane) {
|
|
37
|
+
this.gameObject.add(this.backgroundPlane);
|
|
38
|
+
this.backgroundPlane.visible = false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
onDisable(): void {
|
|
43
|
+
this.context.pre_render_callbacks = this.context.pre_render_callbacks.filter(cb => cb !== this._preRender);
|
|
44
|
+
|
|
45
|
+
if (this.backgroundPlane)
|
|
46
|
+
this.gameObject.remove(this.backgroundPlane);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private backgroundPlane?: Mesh;
|
|
50
|
+
private threeTexture?: Texture;
|
|
51
|
+
private forceTextureInitialization = function() {
|
|
52
|
+
const material = new MeshBasicMaterial();
|
|
53
|
+
const geometry = new PlaneGeometry();
|
|
54
|
+
const scene = new Scene();
|
|
55
|
+
scene.add(new Mesh(geometry, material));
|
|
56
|
+
const camera = new ThreeCamera();
|
|
57
|
+
|
|
58
|
+
return function forceTextureInitialization(renderer, texture) {
|
|
59
|
+
material.map = texture;
|
|
60
|
+
renderer.render(scene, camera);
|
|
61
|
+
};
|
|
62
|
+
}();
|
|
63
|
+
|
|
64
|
+
// TODO should only attach on session start, and detach on session end
|
|
65
|
+
private preRender() {
|
|
66
|
+
if (!this || !this.gameObject) return;
|
|
67
|
+
|
|
68
|
+
const xr = this.context.renderer.xr;
|
|
69
|
+
const frame = xr.getFrame();
|
|
70
|
+
|
|
71
|
+
if (frame) {
|
|
72
|
+
|
|
73
|
+
// We're generating a new texture here, and force three to initialize it
|
|
74
|
+
// from https://stackoverflow.com/a/55084367 to inject a custom texture into three.js
|
|
75
|
+
if (!this.threeTexture && this.context.renderer) {
|
|
76
|
+
this.threeTexture = new Texture();
|
|
77
|
+
// this.threeTexture.encoding = LinearEncoding;
|
|
78
|
+
this.forceTextureInitialization(this.context.renderer, this.threeTexture);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// simple mesh and fullscreen shader to display the camera texture
|
|
82
|
+
// from three: WebGLBackground
|
|
83
|
+
if (this.backgroundPlane === undefined) {
|
|
84
|
+
this.backgroundPlane = makeFullscreenPlane(this.backgroundTint);
|
|
85
|
+
this.gameObject.add(this.backgroundPlane);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// WebXR Raw Camera Access -
|
|
89
|
+
// we composite the camera texture into the scene background by rendering it first.
|
|
90
|
+
this.updateFromFrame(frame);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
if (this.planeMesh) {
|
|
95
|
+
this.planeMesh.visible = frame != null;
|
|
96
|
+
}
|
|
97
|
+
*/
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
onBeforeRender(frame: XRFrame | null) {
|
|
101
|
+
this.updateFromFrame(frame);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
updateFromFrame(frame: XRFrame | null) {
|
|
105
|
+
if (!frame) return;
|
|
106
|
+
|
|
107
|
+
// https://chromium.googlesource.com/chromium/src/+/7c5ac3c0f95b97cf12be95a5c1c0a8ff163246d8/third_party/webxr_test_pages/webxr-samples/proposals/camera-access-barebones.html
|
|
108
|
+
const pose = frame.getViewerPose(this.context.renderer.xr.getReferenceSpace()!);
|
|
109
|
+
if (pose) {
|
|
110
|
+
for( const view of pose.views) {
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
if ('camera' in view && view.camera) {
|
|
113
|
+
const xrManager = this.context.renderer.xr;
|
|
114
|
+
let binding = xrManager.getBinding();
|
|
115
|
+
// not sure how / why this can be null, but we can recreate it here
|
|
116
|
+
if (!binding) binding = new XRWebGLBinding( frame.session, this.context.renderer.getContext() );
|
|
117
|
+
|
|
118
|
+
if (binding) {
|
|
119
|
+
let glImage: WebGLTexture | null = null;
|
|
120
|
+
if ('getCameraImage' in binding) {
|
|
121
|
+
// @ts-ignore
|
|
122
|
+
glImage = binding.getCameraImage(view.camera);
|
|
123
|
+
|
|
124
|
+
// discussion on exactly this:
|
|
125
|
+
// https://discourse.threejs.org/t/using-a-webgltexture-as-texture-for-three-js/46245/8
|
|
126
|
+
// HACK from https://stackoverflow.com/a/55084367 to inject a custom texture into three.js
|
|
127
|
+
const texProps = this.context.renderer.properties.get(this.threeTexture);
|
|
128
|
+
texProps.__webglTexture = glImage;
|
|
129
|
+
|
|
130
|
+
if (this.backgroundPlane) {
|
|
131
|
+
//@ts-ignore
|
|
132
|
+
this.backgroundPlane.setTexture(this.threeTexture);
|
|
133
|
+
this.backgroundPlane.visible = true;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// console.error(view.camera, xrManager)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
// console.error("NO CAMERA IN VIEW")
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
// console.error(this.context.renderer.xr.getReferenceSpace(), frame);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// TODO tint could be an uniform
|
|
152
|
+
let backgroundFragment: string = /* glsl */`
|
|
153
|
+
uniform sampler2D t2D;
|
|
154
|
+
|
|
155
|
+
varying vec2 vUv;
|
|
156
|
+
|
|
157
|
+
void main() {
|
|
158
|
+
|
|
159
|
+
vec4 texColor = texture2D( t2D, vUv );
|
|
160
|
+
texColor.w = 1.0;
|
|
161
|
+
|
|
162
|
+
// inline sRGB decode
|
|
163
|
+
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
|
|
164
|
+
|
|
165
|
+
gl_FragColor = texColor * <backgroundTint>;
|
|
166
|
+
|
|
167
|
+
#include <tonemapping_fragment>
|
|
168
|
+
#include <encodings_fragment>
|
|
169
|
+
|
|
170
|
+
}
|
|
171
|
+
`;
|
|
172
|
+
|
|
173
|
+
// not sure where we want to move this and in which form is best (extends Object3D?)
|
|
174
|
+
export function makeFullscreenPlane(tint: RGBAColor ) {
|
|
175
|
+
const replacementTint = "vec4(" + tint.r.toFixed(3) + "," + tint.g.toFixed(3) + "," + tint.b.toFixed(3) + "," + tint.a.toFixed(3) + ")";
|
|
176
|
+
console.log(replacementTint);
|
|
177
|
+
const planeMesh = new Mesh(
|
|
178
|
+
new PlaneGeometry(2, 2),
|
|
179
|
+
// @ts-ignore
|
|
180
|
+
new ShaderMaterial({
|
|
181
|
+
name: 'BackgroundMaterial',
|
|
182
|
+
uniforms: UniformsUtils.clone( ShaderLib.background.uniforms ),
|
|
183
|
+
vertexShader: ShaderLib.background.vertexShader,
|
|
184
|
+
fragmentShader: backgroundFragment.replace("<backgroundTint>", replacementTint), // ShaderLib.background.fragmentShader,
|
|
185
|
+
side: DoubleSide,
|
|
186
|
+
depthTest: false,
|
|
187
|
+
depthWrite: false,
|
|
188
|
+
fog: false
|
|
189
|
+
})
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
planeMesh.geometry.deleteAttribute( 'normal' );
|
|
193
|
+
|
|
194
|
+
// add "map" material property so the renderer can evaluate it like for built-in materials
|
|
195
|
+
Object.defineProperty( planeMesh.material, 'map', {
|
|
196
|
+
get: function () {
|
|
197
|
+
return this.threeTexture;
|
|
198
|
+
}
|
|
199
|
+
} );
|
|
200
|
+
|
|
201
|
+
// Option 1: add the planeMesh to our scene for rendering.
|
|
202
|
+
// This is useful for applying custom shader effects on the background (instead of using the system composite)
|
|
203
|
+
planeMesh.renderOrder = -10000; // render first
|
|
204
|
+
planeMesh.layers.disableAll();
|
|
205
|
+
planeMesh.layers.enable(2); // ignore raycasts
|
|
206
|
+
planeMesh.frustumCulled = false;
|
|
207
|
+
|
|
208
|
+
// should be a class, for now lets just define a method for the weird way the texture needs to be set
|
|
209
|
+
// @ts-ignore
|
|
210
|
+
planeMesh.setTexture = function(texture) {
|
|
211
|
+
planeMesh.material.uniforms.t2D.value = texture;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return planeMesh;
|
|
215
|
+
}
|
|
@@ -84,10 +84,11 @@ export class WebARSessionRoot extends Behaviour {
|
|
|
84
84
|
|
|
85
85
|
if (this._isTouching) {
|
|
86
86
|
// callbacks
|
|
87
|
-
|
|
87
|
+
const poseMatrix = new Matrix4().fromArray(pose.transform.matrix).invert();
|
|
88
|
+
this.dispatchEvent(new CustomEvent('placedSession', { detail: { pose, poseMatrix } }));
|
|
88
89
|
|
|
89
90
|
if (this.webAR) this.webAR.setReticleActive(false);
|
|
90
|
-
this.placeAt(rig,
|
|
91
|
+
this.placeAt(rig, poseMatrix);
|
|
91
92
|
return true;
|
|
92
93
|
}
|
|
93
94
|
}
|
|
@@ -78,6 +78,11 @@ export class WebXR extends Behaviour {
|
|
|
78
78
|
public static get IsARSupported(): boolean { return arSupported; }
|
|
79
79
|
public static get IsVRSupported(): boolean { return vrSupported; }
|
|
80
80
|
|
|
81
|
+
private static _optionalFeatures_VR: string[] = ['local-floor', 'bounded-floor', 'hand-tracking', 'high-fixed-foveation-level', 'layers'];
|
|
82
|
+
private static _optionalFeatures_AR: string[] = ['plane-detection', 'anchors', 'local-floor', 'hand-tracking', 'layers'];
|
|
83
|
+
public static get OptionalFeatures_VR(): string[] { return this._optionalFeatures_VR; }
|
|
84
|
+
public static get OptionalFeatures_AR(): string[] { return this._optionalFeatures_AR; }
|
|
85
|
+
|
|
81
86
|
public static addEventListener(type: string, listener: any): any {
|
|
82
87
|
this.events.addEventListener(type, listener);
|
|
83
88
|
return listener;
|
|
@@ -93,7 +98,8 @@ export class WebXR extends Behaviour {
|
|
|
93
98
|
}
|
|
94
99
|
else
|
|
95
100
|
webXR.__internalAwake();
|
|
96
|
-
const
|
|
101
|
+
const options = { optionalFeatures: WebXR.OptionalFeatures_VR };
|
|
102
|
+
const vrButton = VRButton.createButton(webXR.context.renderer, options);
|
|
97
103
|
vrButton.classList.add('webxr-ar-button');
|
|
98
104
|
vrButton.classList.add('webxr-button');
|
|
99
105
|
this.resetButtonStyles(vrButton);
|
|
@@ -106,19 +112,17 @@ export class WebXR extends Behaviour {
|
|
|
106
112
|
public static createARButton(webXR: WebXR, opts?: CreateButtonOptions): HTMLButtonElement | HTMLAnchorElement {
|
|
107
113
|
webXR.__internalAwake();
|
|
108
114
|
const domOverlayRoot = webXR.webAR?.getAROverlayContainer();
|
|
109
|
-
const
|
|
115
|
+
const options: any = { optionalFeatures: [...this.OptionalFeatures_AR] };
|
|
110
116
|
if (domOverlayRoot) {
|
|
111
|
-
|
|
112
|
-
|
|
117
|
+
options.domOverlay = { root: domOverlayRoot };
|
|
118
|
+
options.optionalFeatures.push('dom-overlay')
|
|
119
|
+
options.optionalFeatures.push('hit-test');
|
|
113
120
|
}
|
|
114
121
|
else {
|
|
115
122
|
console.warn("No dom overlay root found, HTML overlays on top of screen-based AR will not work.");
|
|
116
123
|
}
|
|
117
|
-
features.optionalFeatures.push('plane-detection');
|
|
118
|
-
// features.optionalFeatures.push('light-estimation');
|
|
119
|
-
features.optionalFeatures.push('anchors');
|
|
120
124
|
|
|
121
|
-
const arButton = ARButton.createButton(webXR.context.renderer,
|
|
125
|
+
const arButton = ARButton.createButton(webXR.context.renderer, options);
|
|
122
126
|
arButton.classList.add('webxr-ar-button');
|
|
123
127
|
arButton.classList.add('webxr-button');
|
|
124
128
|
WebXR.resetButtonStyles(arButton);
|
|
@@ -9,7 +9,6 @@ import { AssetReference } from "../engine/engine_addressables";
|
|
|
9
9
|
import { Object3D } from "three";
|
|
10
10
|
import { VRUserState } from "./WebXRSync";
|
|
11
11
|
import { getParam } from "../engine/engine_utils";
|
|
12
|
-
import { serializable } from "../engine/engine_serialization_decorator";
|
|
13
12
|
import { ViewDevice } from "../engine/engine_playerview";
|
|
14
13
|
import { InstancingUtil } from "../engine/engine_instancing";
|
|
15
14
|
|
|
@@ -332,6 +331,7 @@ export class WebXRAvatar {
|
|
|
332
331
|
if (this.flags.length <= 0) {
|
|
333
332
|
if (this.head) {
|
|
334
333
|
const flag = GameObject.addNewComponent(this.head, XRFlag) as XRFlag;
|
|
334
|
+
// TODO: the defaults are wrong? should be Desktop | ThirdPerson ?
|
|
335
335
|
flag.visibleIn = XRStateFlag.ThirdPerson | XRStateFlag.VR;
|
|
336
336
|
this.flags.push(flag);
|
|
337
337
|
if (debug)
|
|
@@ -54,8 +54,8 @@ export class XRGrabRendering extends Behaviour {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
onDisable(): void {
|
|
57
|
-
this.context.connection.
|
|
58
|
-
this.context.connection.
|
|
57
|
+
this.context.connection.stopListen(XRGrabEvent.StartOrUpdate, this._addOrUpdateSub);
|
|
58
|
+
this.context.connection.stopListen(XRGrabEvent.End, this._endSub);
|
|
59
59
|
AttachedObject.RemoveEventListener(AttachedObjectEvents.WillFree, this._freeSub);
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -253,7 +253,7 @@ export class WebXRSync extends Behaviour {
|
|
|
253
253
|
this.avatars[evt.id] = undefined;
|
|
254
254
|
}
|
|
255
255
|
});
|
|
256
|
-
this.context.connection.
|
|
256
|
+
this.context.connection.beginListenBinary(VRUserStateBufferIdentifier, (state: VrUserStateBuffer) => {
|
|
257
257
|
// console.log("BUFFER", state);
|
|
258
258
|
const guid = state.guid();
|
|
259
259
|
if (!guid) return;
|
|
@@ -299,7 +299,7 @@ export class WebXRSync extends Behaviour {
|
|
|
299
299
|
|
|
300
300
|
onDisable() {
|
|
301
301
|
if (this.eventSub_ConnectionEvent)
|
|
302
|
-
this.context.connection.
|
|
302
|
+
this.context.connection.stopListen(RoomEvents.JoinedRoom, this.eventSub_ConnectionEvent);
|
|
303
303
|
WebXR.removeEventListener(WebXREvent.XRStarted, this.eventSub_WebXRStartEvent);
|
|
304
304
|
WebXR.removeEventListener(WebXREvent.XRUpdate, this.eventSub_WebXRUpdateEvent);
|
|
305
305
|
WebXR.removeEventListener(WebXREvent.XRStopped, this.eventSub_WebXREndEvent);
|
|
@@ -7,6 +7,7 @@ export { AnimationExtension } from "../export/usdz/extensions/Animation";
|
|
|
7
7
|
export { AnimationTrackHandler } from "../timeline/TimelineTracks";
|
|
8
8
|
export { Animator } from "../Animator";
|
|
9
9
|
export { AnimatorController } from "../AnimatorController";
|
|
10
|
+
export { Antialiasing } from "../postprocessing/Effects/Antialiasing";
|
|
10
11
|
export { AttachedObject } from "../WebXRController";
|
|
11
12
|
export { AudioListener } from "../AudioListener";
|
|
12
13
|
export { AudioSource } from "../AudioSource";
|
|
@@ -23,6 +24,7 @@ export { AvatarModel } from "../AvatarLoader";
|
|
|
23
24
|
export { AxesHelper } from "../AxesHelper";
|
|
24
25
|
export { BaseUIComponent } from "../ui/BaseUIComponent";
|
|
25
26
|
export { BasicIKConstraint } from "../BasicIKConstraint";
|
|
27
|
+
export { Bloom } from "../postprocessing/Effects/Bloom";
|
|
26
28
|
export { BoxCollider } from "../Collider";
|
|
27
29
|
export { BoxGizmo } from "../Gizmos";
|
|
28
30
|
export { BoxHelperComponent } from "../BoxHelperComponent";
|
|
@@ -34,13 +36,15 @@ export { CanvasGroup } from "../ui/CanvasGroup";
|
|
|
34
36
|
export { CapsuleCollider } from "../Collider";
|
|
35
37
|
export { CharacterController } from "../CharacterController";
|
|
36
38
|
export { CharacterControllerInput } from "../CharacterController";
|
|
39
|
+
export { ChromaticAberration } from "../postprocessing/Effects/ChromaticAberration";
|
|
37
40
|
export { Collider } from "../Collider";
|
|
38
|
-
export { ColorAdjustments } from "../
|
|
41
|
+
export { ColorAdjustments } from "../postprocessing/Effects/ColorAdjustments";
|
|
39
42
|
export { ColorBySpeedModule } from "../ParticleSystemModules";
|
|
40
43
|
export { ColorOverLifetimeModule } from "../ParticleSystemModules";
|
|
41
44
|
export { ControlTrackHandler } from "../timeline/TimelineTracks";
|
|
42
45
|
export { Deletable } from "../DeleteBox";
|
|
43
46
|
export { DeleteBox } from "../DeleteBox";
|
|
47
|
+
export { DepthOfField } from "../postprocessing/Effects/DepthOfField";
|
|
44
48
|
export { DeviceFlag } from "../DeviceFlag";
|
|
45
49
|
export { DragControls } from "../DragControls";
|
|
46
50
|
export { DropListener } from "../DropListener";
|
|
@@ -92,9 +96,11 @@ export { ParticleBurst } from "../ParticleSystemModules";
|
|
|
92
96
|
export { ParticleSubEmitter } from "../ParticleSystemSubEmitter";
|
|
93
97
|
export { ParticleSystem } from "../ParticleSystem";
|
|
94
98
|
export { ParticleSystemRenderer } from "../ParticleSystem";
|
|
99
|
+
export { PixelationEffect } from "../postprocessing/Effects/Pixelation";
|
|
95
100
|
export { PlayableDirector } from "../timeline/PlayableDirector";
|
|
96
101
|
export { PlayerColor } from "../PlayerColor";
|
|
97
102
|
export { PointerEventData } from "../ui/PointerEvents";
|
|
103
|
+
export { PostProcessingHandler } from "../postprocessing/PostProcessingHandler";
|
|
98
104
|
export { RawImage } from "../ui/Image";
|
|
99
105
|
export { Raycaster } from "../ui/Raycaster";
|
|
100
106
|
export { Rect } from "../ui/RectTransform";
|
|
@@ -109,6 +115,7 @@ export { Rigidbody } from "../RigidBody";
|
|
|
109
115
|
export { RotationBySpeedModule } from "../ParticleSystemModules";
|
|
110
116
|
export { RotationOverLifetimeModule } from "../ParticleSystemModules";
|
|
111
117
|
export { ScreenCapture } from "../ScreenCapture";
|
|
118
|
+
export { ScreenSpaceAmbientOcclusion } from "../postprocessing/Effects/ScreenspaceAmbientOcclusion";
|
|
112
119
|
export { ShadowCatcher } from "../ShadowCatcher";
|
|
113
120
|
export { ShapeModule } from "../ParticleSystemModules";
|
|
114
121
|
export { SignalAsset } from "../timeline/SignalAsset";
|
|
@@ -137,7 +144,7 @@ export { TestRunner } from "../TestRunner";
|
|
|
137
144
|
export { TestSimulateUserData } from "../TestRunner";
|
|
138
145
|
export { Text } from "../ui/Text";
|
|
139
146
|
export { TextureSheetAnimationModule } from "../ParticleSystemModules";
|
|
140
|
-
export { ToneMapping } from "../
|
|
147
|
+
export { ToneMapping } from "../postprocessing/Effects/Tonemapping";
|
|
141
148
|
export { TrailModule } from "../ParticleSystemModules";
|
|
142
149
|
export { TransformData } from "../export/usdz/extensions/Animation";
|
|
143
150
|
export { TransformGizmo } from "../TransformGizmo";
|
|
@@ -148,13 +155,14 @@ export { USDZExporter } from "../export/usdz/USDZExporter";
|
|
|
148
155
|
export { VelocityOverLifetimeModule } from "../ParticleSystemModules";
|
|
149
156
|
export { VerticalLayoutGroup } from "../ui/Layout";
|
|
150
157
|
export { VideoPlayer } from "../VideoPlayer";
|
|
158
|
+
export { Vignette } from "../postprocessing/Effects/Vignette";
|
|
151
159
|
export { Voip } from "../Voip";
|
|
152
|
-
export { Volume } from "../Volume";
|
|
153
|
-
export {
|
|
154
|
-
export {
|
|
155
|
-
export { VolumeProfile } from "../Volume";
|
|
160
|
+
export { Volume } from "../postprocessing/Volume";
|
|
161
|
+
export { VolumeParameter } from "../postprocessing/VolumeParameter";
|
|
162
|
+
export { VolumeProfile } from "../postprocessing/VolumeProfile";
|
|
156
163
|
export { VRUserState } from "../WebXRSync";
|
|
157
164
|
export { WebAR } from "../WebXR";
|
|
165
|
+
export { WebARCameraBackground } from "../WebARCameraBackground";
|
|
158
166
|
export { WebARSessionRoot } from "../WebARSessionRoot";
|
|
159
167
|
export { WebXR } from "../WebXR";
|
|
160
168
|
export { WebXRAvatar } from "../WebXRAvatar";
|