@needle-tools/engine 2.64.0-pre → 2.65.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 +11 -0
- package/dist/needle-engine.js +5078 -5055
- package/dist/needle-engine.umd.cjs +84 -84
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/assets/index.js.map +1 -1
- package/lib/engine/assets/logo.svg +1 -0
- package/lib/engine/codegen/register_types.js +169 -169
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/debug/debug.js.map +1 -1
- package/lib/engine/debug/debug_console.js.map +1 -1
- package/lib/engine/debug/debug_overlay.js.map +1 -1
- package/lib/engine/debug/index.js.map +1 -1
- package/lib/engine/engine.js.map +1 -1
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_application.js.map +1 -1
- package/lib/engine/engine_assetdatabase.js.map +1 -1
- package/lib/engine/engine_camera.js.map +1 -1
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_constants.js.map +1 -1
- package/lib/engine/engine_context_registry.js.map +1 -1
- package/lib/engine/engine_coroutine.js.map +1 -1
- package/lib/engine/engine_create_objects.js.map +1 -1
- package/lib/engine/engine_default_parameters.js.map +1 -1
- package/lib/engine/engine_element.d.ts +6 -4
- package/lib/engine/engine_element.js +152 -165
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_element_overlay.js.map +1 -1
- package/lib/engine/engine_fileloader.js.map +1 -1
- package/lib/engine/engine_gameobject.d.ts +4 -2
- package/lib/engine/engine_gameobject.js +32 -13
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_generic_utils.js.map +1 -1
- package/lib/engine/engine_gizmos.js.map +1 -1
- package/lib/engine/engine_gltf.d.ts +1 -1
- package/lib/engine/engine_gltf.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_hot_reload.js.map +1 -1
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_input_utils.js.map +1 -1
- package/lib/engine/engine_instancing.js.map +1 -1
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_lightdata.js.map +1 -1
- package/lib/engine/engine_loaders.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.js +36 -6
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_math.js.map +1 -1
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking_auto.js.map +1 -1
- package/lib/engine/engine_networking_files.js.map +1 -1
- package/lib/engine/engine_networking_files_default_components.js.map +1 -1
- package/lib/engine/engine_networking_instantiate.js.map +1 -1
- package/lib/engine/engine_networking_peer.js.map +1 -1
- package/lib/engine/engine_networking_types.js.map +1 -1
- package/lib/engine/engine_networking_utils.js.map +1 -1
- package/lib/engine/engine_networking_websocket.js.map +1 -1
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_physics.types.js.map +1 -1
- package/lib/engine/engine_playerview.js.map +1 -1
- package/lib/engine/engine_rendererdata.js.map +1 -1
- package/lib/engine/engine_scenetools.js.map +1 -1
- package/lib/engine/engine_serialization.js.map +1 -1
- package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_serialization_decorator.js.map +1 -1
- package/lib/engine/engine_setup.d.ts +5 -2
- package/lib/engine/engine_setup.js +14 -5
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_shaders.js.map +1 -1
- package/lib/engine/engine_texture.js.map +1 -1
- package/lib/engine/engine_three_utils.js.map +1 -1
- package/lib/engine/engine_time.js.map +1 -1
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_typestore.js.map +1 -1
- package/lib/engine/engine_util_decorator.js.map +1 -1
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/engine_utils_screenshot.js.map +1 -1
- package/lib/engine/engine_web_api.js.map +1 -1
- package/lib/engine/extensions/EXT_texture_exr.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_animator_controller_model.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_components.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_gameobject_data.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_lighting_settings.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_lightmaps.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_persistent_assets.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_progressive.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_render_objects.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine/extensions/extension_resolver.js.map +1 -1
- package/lib/engine/extensions/extension_utils.js.map +1 -1
- package/lib/engine/extensions/extensions.js.map +1 -1
- package/lib/engine/js-extensions/Camera.js.map +1 -1
- package/lib/engine/js-extensions/Layers.js.map +1 -1
- package/lib/engine/js-extensions/index.js.map +1 -1
- package/lib/engine/shaders/shaderData.js.map +1 -1
- package/lib/engine/tests/test_utils.js.map +1 -1
- package/lib/engine-components/AlignmentConstraint.js.map +1 -1
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/AnimationCurve.js.map +1 -1
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/AudioListener.js.map +1 -1
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/AvatarLoader.js.map +1 -1
- package/lib/engine-components/AxesHelper.js.map +1 -1
- package/lib/engine-components/BasicIKConstraint.js.map +1 -1
- package/lib/engine-components/BoxCollider.js.map +1 -1
- package/lib/engine-components/BoxHelperComponent.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +3 -1
- package/lib/engine-components/Camera.js +11 -10
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/CharacterController.js.map +1 -1
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +1 -1
- package/lib/engine-components/Component.js +2 -2
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/DeleteBox.js.map +1 -1
- package/lib/engine-components/DeviceFlag.js.map +1 -1
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/Duplicatable.js.map +1 -1
- package/lib/engine-components/EventList.js.map +1 -1
- package/lib/engine-components/EventTrigger.js.map +1 -1
- package/lib/engine-components/EventType.js.map +1 -1
- package/lib/engine-components/FlyControls.js.map +1 -1
- package/lib/engine-components/Fog.js.map +1 -1
- package/lib/engine-components/Gizmos.js.map +1 -1
- package/lib/engine-components/GridHelper.js.map +1 -1
- package/lib/engine-components/GroundProjection.js.map +1 -1
- package/lib/engine-components/Interactable.js.map +1 -1
- package/lib/engine-components/Joints.js.map +1 -1
- package/lib/engine-components/LODGroup.js.map +1 -1
- package/lib/engine-components/Light.d.ts +0 -2
- package/lib/engine-components/Light.js +22 -14
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/LookAtConstraint.js.map +1 -1
- package/lib/engine-components/NestedGltf.js.map +1 -1
- package/lib/engine-components/Networking.js.map +1 -1
- package/lib/engine-components/OffsetConstraint.js.map +1 -1
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/ParticleSystemModules.js.map +1 -1
- package/lib/engine-components/ParticleSystemSubEmitter.js.map +1 -1
- package/lib/engine-components/PlayerColor.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/RendererLightmap.js.map +1 -1
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/ShadowCatcher.js.map +1 -1
- package/lib/engine-components/Skybox.d.ts +2 -0
- package/lib/engine-components/Skybox.js +43 -21
- package/lib/engine-components/Skybox.js.map +1 -1
- package/lib/engine-components/SmoothFollow.js.map +1 -1
- package/lib/engine-components/SpatialTrigger.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SphereCollider.js.map +1 -1
- package/lib/engine-components/SpriteRenderer.js.map +1 -1
- package/lib/engine-components/SyncedCamera.js.map +1 -1
- package/lib/engine-components/SyncedRoom.js.map +1 -1
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/TestRunner.js.map +1 -1
- package/lib/engine-components/TransformGizmo.js.map +1 -1
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/Voip.js.map +1 -1
- package/lib/engine-components/Volume.js +2 -0
- package/lib/engine-components/Volume.js.map +1 -1
- package/lib/engine-components/WebARSessionRoot.js.map +1 -1
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/WebXRAvatar.js.map +1 -1
- package/lib/engine-components/WebXRController.js.map +1 -1
- package/lib/engine-components/WebXRGrabRendering.js.map +1 -1
- package/lib/engine-components/WebXRRig.js.map +1 -1
- package/lib/engine-components/WebXRSync.js.map +1 -1
- package/lib/engine-components/XRFlag.js.map +1 -1
- package/lib/engine-components/avatar/AvatarBlink_Simple.js.map +1 -1
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js.map +1 -1
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +1 -1
- package/lib/engine-components/avatar/Avatar_MouthShapes.js.map +1 -1
- package/lib/engine-components/avatar/Avatar_MustacheShake.js.map +1 -1
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/debug/LogStats.js.map +1 -1
- package/lib/engine-components/export/gltf/GltfExport.js.map +1 -1
- package/lib/engine-components/export/usdz/Extension.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/Animation.js.map +1 -1
- package/lib/engine-components/export/usdz/types.js.map +1 -1
- package/lib/engine-components/export/usdz/utils/animationutils.js.map +1 -1
- package/lib/engine-components/export/usdz/utils/quicklook.js.map +1 -1
- package/lib/engine-components/export/usdz/utils/timeutils.js.map +1 -1
- package/lib/engine-components/js-extensions/ExtensionUtils.js.map +1 -1
- package/lib/engine-components/js-extensions/Object3D.js +1 -1
- package/lib/engine-components/js-extensions/Object3D.js.map +1 -1
- package/lib/engine-components/js-extensions/RGBAColor.js.map +1 -1
- package/lib/engine-components/js-extensions/Vector.js.map +1 -1
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/timeline/SignalAsset.js.map +1 -1
- package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/ui/BaseUIComponent.js.map +1 -1
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/Canvas.js +2 -2
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/CanvasGroup.js.map +1 -1
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/lib/engine-components/ui/Graphic.js.map +1 -1
- package/lib/engine-components/ui/Image.js.map +1 -1
- package/lib/engine-components/ui/InputField.js.map +1 -1
- package/lib/engine-components/ui/Interfaces.js.map +1 -1
- package/lib/engine-components/ui/Keyboard.js.map +1 -1
- package/lib/engine-components/ui/Layout.js.map +1 -1
- package/lib/engine-components/ui/PointerEvents.js.map +1 -1
- package/lib/engine-components/ui/RaycastUtils.js.map +1 -1
- package/lib/engine-components/ui/Raycaster.js.map +1 -1
- package/lib/engine-components/ui/RectTransform.js.map +1 -1
- package/lib/engine-components/ui/SpatialHtml.js.map +1 -1
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/ui/Utils.js.map +1 -1
- package/lib/engine-components-experimental/Presentation.js.map +1 -1
- package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -1
- package/lib/engine-schemes/schemes.js.map +1 -1
- package/lib/engine-schemes/synced-camera-model.js.map +1 -1
- package/lib/engine-schemes/synced-transform-model.js.map +1 -1
- package/lib/engine-schemes/transform.js.map +1 -1
- package/lib/engine-schemes/vec2.js.map +1 -1
- package/lib/engine-schemes/vec3.js.map +1 -1
- package/lib/engine-schemes/vec4.js.map +1 -1
- package/lib/engine-schemes/vr-user-state-buffer.js.map +1 -1
- package/lib/include/three/ARButton.js.map +1 -1
- package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js.map +1 -1
- package/lib/include/three/VRButton.js.map +1 -1
- package/lib/needle-engine.js.map +1 -1
- package/package.json +16 -3
- package/plugins/generate-font.js +65 -0
- package/plugins/vite/poster-client.js +3 -5
- package/plugins/vite/reload.js +2 -2
- package/src/engine/codegen/register_types.js +171 -171
- package/src/engine/engine_element.ts +162 -178
- package/src/engine/engine_gameobject.ts +583 -558
- package/src/engine/engine_gltf.ts +1 -1
- package/src/engine/engine_mainloop_utils.ts +36 -7
- package/src/engine/engine_setup.ts +20 -7
- package/src/engine-components/Camera.ts +14 -12
- package/src/engine-components/Component.ts +2 -2
- package/src/engine-components/Light.ts +20 -13
- package/src/engine-components/Skybox.ts +49 -22
- package/src/engine-components/Volume.ts +1 -0
- package/src/engine-components/js-extensions/Object3D.ts +1 -1
- package/src/engine-components/ui/Canvas.ts +2 -2
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/vite.config.d.ts +0 -2
- package/lib/vite.config.js +0 -26
- package/lib/vite.config.js.map +0 -1
- package/src/tsconfig.json +0 -33
|
@@ -9,7 +9,7 @@ export interface INeedleGltfLoader {
|
|
|
9
9
|
createBuiltinComponents(context: Context, gltfId: SourceIdentifier, gltf, seed: number | null | UIDProvider, extension?: NEEDLE_components): Promise<void>
|
|
10
10
|
writeBuiltinComponentData(comp: object, context: SerializationContext);
|
|
11
11
|
parseSync(context: Context, data, path: string, seed: number | UIDProvider | null): Promise<GLTF | undefined>;
|
|
12
|
-
loadSync(context: Context, url: string, seed: number | UIDProvider | null, _allowAddingAnimator: boolean, prog?: (ProgressEvent) => void): Promise<GLTF | undefined>
|
|
12
|
+
loadSync(context: Context, url: string, seed: number | UIDProvider | null, _allowAddingAnimator: boolean, prog?: (prog : ProgressEvent) => void): Promise<GLTF | undefined>
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
let gltfLoader: INeedleGltfLoader;
|
|
@@ -17,7 +17,7 @@ const new_scripts_buffer: any[] = [];
|
|
|
17
17
|
export function processNewScripts(context: IContext) {
|
|
18
18
|
if (context.new_scripts.length <= 0) return;
|
|
19
19
|
if (debug)
|
|
20
|
-
console.log("Register new components", context.new_scripts.length, context.alias ? ("element: " + context.alias) : "");
|
|
20
|
+
console.log("Register new components", context.new_scripts.length, [...context.new_scripts], context.alias ? ("element: " + context.alias) : context["hash"], context);
|
|
21
21
|
|
|
22
22
|
// if(new_scripts_post_setup_callbacks.length > 0) console.log(new_scripts_post_setup_callbacks);
|
|
23
23
|
if (context.new_scripts_pre_setup_callbacks.length > 0) {
|
|
@@ -222,14 +222,22 @@ export function updateIsActive(obj?: Object3D) {
|
|
|
222
222
|
console.trace("Invalid call - no current context.");
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
225
|
-
updateIsActiveInHierarchyRecursiveRuntime(obj, isActiveSelf(obj), true);
|
|
225
|
+
const wasSuccessful = updateIsActiveInHierarchyRecursiveRuntime(obj, isActiveSelf(obj), true);
|
|
226
|
+
if (!wasSuccessful) {
|
|
227
|
+
console.error("Failed to update active state in hierarchy of \"" + obj.name + "\"", obj);
|
|
228
|
+
console.warn(" ↑ this error might be caused by circular references. Please make sure you don't have files with circular references (e.g. one GLB 1 is loading GLB 2 which is then loading GLB 1 again).")
|
|
229
|
+
}
|
|
226
230
|
}
|
|
227
231
|
|
|
232
|
+
function updateIsActiveInHierarchyRecursiveRuntime(go: THREE.Object3D, activeInHierarchy: boolean, allowEventCall: boolean, level: number = 0) {
|
|
233
|
+
if (level > 1000) {
|
|
234
|
+
console.warn("Hierarchy is too deep (> 1000 level) - will abort updating active state");
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
228
237
|
|
|
229
|
-
|
|
230
|
-
|
|
238
|
+
const isActive = isActiveSelf(go);
|
|
231
239
|
if (activeInHierarchy) {
|
|
232
|
-
activeInHierarchy =
|
|
240
|
+
activeInHierarchy = isActive;
|
|
233
241
|
// IF we update activeInHierarchy within a disabled hierarchy we need to check the parent
|
|
234
242
|
if (activeInHierarchy && go.parent) {
|
|
235
243
|
activeInHierarchy = go.parent[constants.activeInHierarchyFieldName]
|
|
@@ -243,7 +251,7 @@ function updateIsActiveInHierarchyRecursiveRuntime(go: THREE.Object3D, activeInH
|
|
|
243
251
|
// only raise events here if we didnt call enable etc already
|
|
244
252
|
if (changed) {
|
|
245
253
|
if (debugHierarchy)
|
|
246
|
-
console.warn("ACTIVE CHANGE", go.name, activeInHierarchy, "changed?" + changed, go
|
|
254
|
+
console.warn("ACTIVE CHANGE", go.name, isActive, go.visible, activeInHierarchy, "changed?" + changed, go);
|
|
247
255
|
if (allowEventCall) {
|
|
248
256
|
perComponent(go, comp => {
|
|
249
257
|
if (activeInHierarchy) {
|
|
@@ -263,13 +271,34 @@ function updateIsActiveInHierarchyRecursiveRuntime(go: THREE.Object3D, activeInH
|
|
|
263
271
|
}
|
|
264
272
|
}
|
|
265
273
|
|
|
274
|
+
let success = true;
|
|
266
275
|
if (go.children) {
|
|
276
|
+
const nextLevel = level + 1;
|
|
267
277
|
for (const ch of go.children) {
|
|
268
|
-
updateIsActiveInHierarchyRecursiveRuntime(ch, activeInHierarchy, allowEventCall);
|
|
278
|
+
const res = updateIsActiveInHierarchyRecursiveRuntime(ch, activeInHierarchy, allowEventCall, nextLevel);
|
|
279
|
+
if (res === false) success = false;
|
|
269
280
|
}
|
|
270
281
|
}
|
|
282
|
+
return success;
|
|
271
283
|
}
|
|
272
284
|
|
|
285
|
+
// let isRunning = false;
|
|
286
|
+
// // Prevent: https://github.com/needle-tools/needle-tiny/issues/641
|
|
287
|
+
// const temporyChildArrayBuffer: Array<Array<THREE.Object3D>> = [];
|
|
288
|
+
// export function* iterateChildrenSafe(obj: Object3D) {
|
|
289
|
+
// if (!obj || !obj.children) yield null;
|
|
290
|
+
// // if(isRunning) return;
|
|
291
|
+
// // isRunning = true;
|
|
292
|
+
// const arr = temporyChildArrayBuffer.pop() || [];
|
|
293
|
+
// arr.push(...obj.children);
|
|
294
|
+
// for (const ch of arr) {
|
|
295
|
+
// yield ch;
|
|
296
|
+
// }
|
|
297
|
+
// // isRunning = false;
|
|
298
|
+
// arr.length = 0;
|
|
299
|
+
// temporyChildArrayBuffer.push(arr);
|
|
300
|
+
// }
|
|
301
|
+
|
|
273
302
|
export function updateActiveInHierarchyWithoutEventCall(go: THREE.Object3D) {
|
|
274
303
|
let activeInHierarchy = true;
|
|
275
304
|
let current: THREE.Object3D | null = go;
|
|
@@ -48,8 +48,8 @@ export declare class LoadingOptions {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
export class ContextArgs {
|
|
51
|
-
name
|
|
52
|
-
alias
|
|
51
|
+
name?: string;
|
|
52
|
+
alias?: string;
|
|
53
53
|
domElement: HTMLElement | null;
|
|
54
54
|
renderer?: THREE.WebGLRenderer = undefined;
|
|
55
55
|
hash?: string;
|
|
@@ -227,6 +227,8 @@ export class Context implements IContext {
|
|
|
227
227
|
lightmaps: ILightDataRegistry;
|
|
228
228
|
players: PlayerViewManager;
|
|
229
229
|
|
|
230
|
+
get isCreated() { return this._isCreated; }
|
|
231
|
+
|
|
230
232
|
private _sizeChanged: boolean = false;
|
|
231
233
|
private _isCreated: boolean = false;
|
|
232
234
|
private _isVisible: boolean = false;
|
|
@@ -287,9 +289,17 @@ export class Context implements IContext {
|
|
|
287
289
|
resizeObserver.observe(this.domElement);
|
|
288
290
|
this._disposeCallbacks.push(() => resizeObserver.disconnect());
|
|
289
291
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
292
|
+
this._intersectionObserver = new IntersectionObserver(entries => {
|
|
293
|
+
this._isVisible = entries[0].isIntersecting;
|
|
294
|
+
});
|
|
295
|
+
this._disposeCallbacks.push(() => this._intersectionObserver?.disconnect());
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
private _intersectionObserver: IntersectionObserver | null = null;
|
|
300
|
+
private internalOnUpdateVisible() {
|
|
301
|
+
this._intersectionObserver?.disconnect();
|
|
302
|
+
this._intersectionObserver?.observe(this.domElement);
|
|
293
303
|
}
|
|
294
304
|
|
|
295
305
|
private _disposeCallbacks: Function[] = [];
|
|
@@ -498,6 +508,8 @@ export class Context implements IContext {
|
|
|
498
508
|
}
|
|
499
509
|
if (!prepare_succeeded) return;
|
|
500
510
|
|
|
511
|
+
this.internalOnUpdateVisible();
|
|
512
|
+
|
|
501
513
|
// console.log(prepare_succeeded);
|
|
502
514
|
|
|
503
515
|
if (!this.isManagedExternally)
|
|
@@ -770,14 +782,15 @@ export class Context implements IContext {
|
|
|
770
782
|
return paused;
|
|
771
783
|
}
|
|
772
784
|
|
|
773
|
-
private evaluatePaused() {
|
|
785
|
+
private evaluatePaused(): boolean {
|
|
774
786
|
if (this.isInXR) return false;
|
|
775
787
|
if (this.isPaused) return true;
|
|
776
788
|
// if the element is not visible use the runInBackground flag to determine if we should continue
|
|
777
789
|
if (this.runInBackground) {
|
|
778
790
|
return false;
|
|
779
791
|
}
|
|
780
|
-
|
|
792
|
+
const paused = !this.isVisibleToUser;
|
|
793
|
+
return paused;
|
|
781
794
|
}
|
|
782
795
|
|
|
783
796
|
private renderRequiredTextures() {
|
|
@@ -2,7 +2,7 @@ import { Behaviour, GameObject } from "./Component";
|
|
|
2
2
|
import { getParam } from "../engine/engine_utils";
|
|
3
3
|
import { serializable } from "../engine/engine_serialization_decorator";
|
|
4
4
|
import { RGBAColor } from "./js-extensions/RGBAColor";
|
|
5
|
-
import { XRSessionMode } from "../engine/engine_setup";
|
|
5
|
+
import { Context, XRSessionMode } from "../engine/engine_setup";
|
|
6
6
|
import { ICamera } from "../engine/engine_types"
|
|
7
7
|
import { showBalloonMessage } from "../engine/debug/debug";
|
|
8
8
|
import { getWorldPosition } from "../engine/engine_three_utils";
|
|
@@ -267,7 +267,7 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
267
267
|
if (this._cam && this.context.mainCameraComponent === this) {
|
|
268
268
|
switch (this._clearFlags) {
|
|
269
269
|
case ClearFlags.Skybox:
|
|
270
|
-
if (this.
|
|
270
|
+
if (Camera.backgroundShouldBeTransparent(this.context)) {
|
|
271
271
|
if (!this.ARBackgroundAlpha || this.ARBackgroundAlpha < 0.001) {
|
|
272
272
|
this.context.scene.background = null;
|
|
273
273
|
this.context.renderer.setClearColor(0x000000, 0);
|
|
@@ -287,7 +287,7 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
287
287
|
if (this._backgroundColor) {
|
|
288
288
|
let alpha = this._backgroundColor.alpha;
|
|
289
289
|
// when in WebXR use ar background alpha override or set to 0
|
|
290
|
-
if (this.
|
|
290
|
+
if (Camera.backgroundShouldBeTransparent(this.context)) {
|
|
291
291
|
alpha = this.ARBackgroundAlpha ?? 0;
|
|
292
292
|
}
|
|
293
293
|
this.context.scene.background = null;
|
|
@@ -302,15 +302,22 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
private
|
|
306
|
-
|
|
305
|
+
private enableSkybox() {
|
|
306
|
+
if (!this._skybox)
|
|
307
|
+
this._skybox = new CameraSkybox(this);
|
|
308
|
+
this._skybox.enable();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** Returns true when in XR on a pass through device where the background shouldbe invisible */
|
|
312
|
+
static backgroundShouldBeTransparent(context:Context) {
|
|
313
|
+
const session = context.renderer.xr?.getSession();
|
|
307
314
|
if (!session) return false;
|
|
308
315
|
const environmentBlendMode = session.environmentBlendMode;
|
|
309
316
|
if (debug)
|
|
310
317
|
showBalloonMessage("Environment blend mode: " + environmentBlendMode + " on " + navigator.userAgent);
|
|
311
318
|
const transparent = environmentBlendMode === 'additive' || environmentBlendMode === 'alpha-blend';
|
|
312
319
|
|
|
313
|
-
if (
|
|
320
|
+
if (context.xrSessionMode === XRSessionMode.ImmersiveAR) {
|
|
314
321
|
if (environmentBlendMode === "opaque") {
|
|
315
322
|
// workaround for Quest 2 returning opaque when it should be alpha-blend
|
|
316
323
|
// check user agent if this is the Quest browser and return true if so
|
|
@@ -323,14 +330,9 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
323
330
|
}
|
|
324
331
|
}
|
|
325
332
|
}
|
|
333
|
+
|
|
326
334
|
return transparent;
|
|
327
335
|
}
|
|
328
|
-
|
|
329
|
-
private enableSkybox() {
|
|
330
|
-
if (!this._skybox)
|
|
331
|
-
this._skybox = new CameraSkybox(this);
|
|
332
|
-
this._skybox.enable();
|
|
333
|
-
}
|
|
334
336
|
}
|
|
335
337
|
|
|
336
338
|
|
|
@@ -30,9 +30,9 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
|
|
|
30
30
|
return isDestroyed(go);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
public static setActive(go: THREE.Object3D, active: boolean, processStart: boolean = true
|
|
33
|
+
public static setActive(go: THREE.Object3D, active: boolean, processStart: boolean = true) {
|
|
34
34
|
if (!go) return;
|
|
35
|
-
setActive(go, active
|
|
35
|
+
setActive(go, active);
|
|
36
36
|
main.updateIsActive(go);
|
|
37
37
|
if (active && processStart)
|
|
38
38
|
main.processStart(Context.Current, go);
|
|
@@ -246,9 +246,9 @@ export class Light extends Behaviour implements ILight {
|
|
|
246
246
|
return vec;
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
public updateIntensity() {
|
|
250
|
-
|
|
251
|
-
}
|
|
249
|
+
// public updateIntensity() {
|
|
250
|
+
// this.intensity = this._intensity;
|
|
251
|
+
// }
|
|
252
252
|
|
|
253
253
|
awake() {
|
|
254
254
|
this.color = new THREE.Color(this.color ?? 0xffffff);
|
|
@@ -256,10 +256,12 @@ export class Light extends Behaviour implements ILight {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
onEnable(): void {
|
|
259
|
+
if(debug) console.log("ENABLE LIGHT", this.name);
|
|
259
260
|
this.createLight();
|
|
260
261
|
if (this.isBaked) return;
|
|
261
262
|
else if (this.light) {
|
|
262
263
|
this.light.visible = true;
|
|
264
|
+
this.light.intensity = this._intensity;
|
|
263
265
|
if (this.selfIsLight) {
|
|
264
266
|
// nothing to do
|
|
265
267
|
}
|
|
@@ -273,8 +275,12 @@ export class Light extends Behaviour implements ILight {
|
|
|
273
275
|
}
|
|
274
276
|
|
|
275
277
|
onDisable() {
|
|
278
|
+
if(debug) console.log("DISABLE LIGHT", this.name);
|
|
276
279
|
if (this.light) {
|
|
277
|
-
this.
|
|
280
|
+
if (this.selfIsLight)
|
|
281
|
+
this.light.intensity = 0;
|
|
282
|
+
else
|
|
283
|
+
this.light.visible = false;
|
|
278
284
|
}
|
|
279
285
|
WebXR.removeEventListener(WebXREvent.XRStarted, this._webXRStartedListener);
|
|
280
286
|
WebXR.removeEventListener(WebXREvent.XRStopped, this._webXREndedListener);
|
|
@@ -286,19 +292,19 @@ export class Light extends Behaviour implements ILight {
|
|
|
286
292
|
|
|
287
293
|
private onWebXRStarted() {
|
|
288
294
|
this._webARRoot = GameObject.getComponentInParent(this.gameObject, WebARSessionRoot) ?? undefined;
|
|
289
|
-
this.startCoroutine(this._updateLightIntensityInARRoutine());
|
|
295
|
+
// this.startCoroutine(this._updateLightIntensityInARRoutine());
|
|
290
296
|
}
|
|
291
297
|
|
|
292
|
-
private *_updateLightIntensityInARRoutine() {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
298
|
+
// private *_updateLightIntensityInARRoutine() {
|
|
299
|
+
// while (this.context.isInAR) {
|
|
300
|
+
// yield;
|
|
301
|
+
// // this.updateIntensity();
|
|
302
|
+
// for (let i = 0; i < 30; i++) yield;
|
|
303
|
+
// }
|
|
304
|
+
// }
|
|
299
305
|
|
|
300
306
|
private onWebXREnded() {
|
|
301
|
-
this.updateIntensity();
|
|
307
|
+
// this.updateIntensity();
|
|
302
308
|
}
|
|
303
309
|
|
|
304
310
|
createLight() {
|
|
@@ -306,6 +312,7 @@ export class Light extends Behaviour implements ILight {
|
|
|
306
312
|
|
|
307
313
|
if (lightAlreadyCreated && !this.light) {
|
|
308
314
|
this.light = this.gameObject as unknown as THREE.Light;
|
|
315
|
+
this.light.name = this.name;
|
|
309
316
|
this._intensity = this.light.intensity;
|
|
310
317
|
|
|
311
318
|
switch (this.type) {
|
|
@@ -4,7 +4,7 @@ import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader.js';
|
|
|
4
4
|
import { EXRLoader } from "three/examples/jsm/loaders/EXRLoader";
|
|
5
5
|
import { EquirectangularRefractionMapping, sRGBEncoding, Texture, TextureLoader } from "three"
|
|
6
6
|
import { syncField } from "../engine/engine_networking_auto";
|
|
7
|
-
|
|
7
|
+
import { Camera } from "./Camera";
|
|
8
8
|
|
|
9
9
|
export class RemoteSkybox extends Behaviour {
|
|
10
10
|
|
|
@@ -22,6 +22,7 @@ export class RemoteSkybox extends Behaviour {
|
|
|
22
22
|
environment: boolean = true;
|
|
23
23
|
|
|
24
24
|
private _loader?: RGBELoader | EXRLoader | TextureLoader;
|
|
25
|
+
private _prevUrl?: string;
|
|
25
26
|
private _prevLoadedEnvironment?: Texture;
|
|
26
27
|
private _prevEnvironment: Texture | null = null;
|
|
27
28
|
private _prevBackground: any = null;
|
|
@@ -33,10 +34,9 @@ export class RemoteSkybox extends Behaviour {
|
|
|
33
34
|
|
|
34
35
|
onDisable() {
|
|
35
36
|
if (this.context.scene.environment === this._prevLoadedEnvironment) {
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
this.context.scene.environment = this._prevEnvironment;
|
|
38
|
+
if (!Camera.backgroundShouldBeTransparent(this.context))
|
|
38
39
|
this.context.scene.background = this._prevBackground;
|
|
39
|
-
}
|
|
40
40
|
this._prevLoadedEnvironment = undefined;
|
|
41
41
|
}
|
|
42
42
|
this.unregisterDropEvents();
|
|
@@ -48,39 +48,66 @@ export class RemoteSkybox extends Behaviour {
|
|
|
48
48
|
console.warn("Potentially invalid skybox url", this.url, "on", this.name);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
if (this._prevUrl === url && this._prevLoadedEnvironment) {
|
|
52
|
+
this.applySkybox();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this._prevLoadedEnvironment?.dispose();
|
|
57
|
+
this._prevLoadedEnvironment = undefined;
|
|
58
|
+
}
|
|
59
|
+
this._prevUrl = url;
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const isEXR = url.endsWith(".exr");
|
|
63
|
+
const isHdr = url.endsWith(".hdr");
|
|
64
|
+
if (isEXR) {
|
|
65
|
+
if (!(this._loader instanceof EXRLoader))
|
|
56
66
|
this._loader = new EXRLoader();
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
}
|
|
68
|
+
else if (isHdr) {
|
|
69
|
+
if (!(this._loader instanceof RGBELoader))
|
|
59
70
|
this._loader = new RGBELoader();
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
if (!(this._loader instanceof TextureLoader))
|
|
62
74
|
this._loader = new TextureLoader();
|
|
63
|
-
}
|
|
64
75
|
}
|
|
76
|
+
|
|
65
77
|
console.log("Loading skybox: " + url);
|
|
66
78
|
const envMap = await this._loader.loadAsync(url);
|
|
67
79
|
if (!envMap) return;
|
|
80
|
+
// Check if we're still enabled
|
|
68
81
|
if (!this.enabled) return;
|
|
82
|
+
// Update the current url
|
|
69
83
|
this.url = url;
|
|
70
|
-
|
|
84
|
+
const nameIndex = url.lastIndexOf("/");
|
|
85
|
+
envMap.name = url.substring(nameIndex >= 0 ? nameIndex + 1 : 0);
|
|
71
86
|
if (this._loader instanceof TextureLoader) {
|
|
72
87
|
envMap.encoding = sRGBEncoding;
|
|
73
88
|
}
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
76
|
-
|
|
89
|
+
this._prevLoadedEnvironment = envMap;
|
|
90
|
+
this.applySkybox();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private applySkybox() {
|
|
94
|
+
const envMap = this._prevLoadedEnvironment;
|
|
95
|
+
if (!envMap) return;
|
|
96
|
+
|
|
97
|
+
envMap.mapping = EquirectangularRefractionMapping;
|
|
98
|
+
envMap.needsUpdate = true;
|
|
99
|
+
|
|
100
|
+
// capture state
|
|
101
|
+
if (this.context.scene.background !== envMap)
|
|
102
|
+
this._prevBackground = this.context.scene.background;
|
|
103
|
+
if (this.context.scene.environment !== envMap)
|
|
104
|
+
this._prevEnvironment = this.context.scene.environment;
|
|
105
|
+
|
|
106
|
+
console.log("Set remote skybox", this.url);
|
|
77
107
|
if (this.environment)
|
|
78
108
|
this.context.scene.environment = envMap;
|
|
79
|
-
if (this.background)
|
|
109
|
+
if (this.background && !Camera.backgroundShouldBeTransparent(this.context))
|
|
80
110
|
this.context.scene.background = envMap;
|
|
81
|
-
this._prevLoadedEnvironment = envMap;
|
|
82
|
-
const nameIndex = url.lastIndexOf("/");
|
|
83
|
-
envMap.name = url.substring(nameIndex >= 0 ? nameIndex + 1 : 0);
|
|
84
111
|
if (this.context.mainCameraComponent?.backgroundBlurriness !== undefined)
|
|
85
112
|
this.context.scene.backgroundBlurriness = this.context.mainCameraComponent.backgroundBlurriness;
|
|
86
113
|
}
|
|
@@ -53,7 +53,7 @@ export class Canvas extends UIRootComponent {
|
|
|
53
53
|
this.onRenderSettingsChanged();
|
|
54
54
|
}
|
|
55
55
|
get castShadows() { return this._castShadows; }
|
|
56
|
-
private _castShadows: boolean =
|
|
56
|
+
private _castShadows: boolean = false;
|
|
57
57
|
|
|
58
58
|
@serializable()
|
|
59
59
|
set receiveShadows(val: boolean) {
|
|
@@ -62,7 +62,7 @@ export class Canvas extends UIRootComponent {
|
|
|
62
62
|
this.onRenderSettingsChanged();
|
|
63
63
|
}
|
|
64
64
|
get receiveShadows() { return this._receiveShadows; }
|
|
65
|
-
private _receiveShadows: boolean =
|
|
65
|
+
private _receiveShadows: boolean = false;
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
@serializable()
|