@needle-tools/engine 2.63.3-pre.1 → 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 +24 -0
- package/dist/needle-engine.js +7853 -7746
- package/dist/needle-engine.umd.cjs +215 -214
- 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.d.ts +1 -1
- package/lib/engine/engine_constants.js +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 +34 -15
- 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.d.ts +1 -0
- package/lib/engine/engine_instancing.js +3 -2
- package/lib/engine/engine_instancing.js.map +1 -1
- package/lib/engine/engine_license.js +14 -13
- 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 +62 -57
- 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.d.ts +1 -0
- package/lib/engine/engine_physics.js +30 -0
- 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 +6 -3
- 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.d.ts +1 -0
- package/lib/engine/engine_time.js +5 -1
- package/lib/engine/engine_time.js.map +1 -1
- package/lib/engine/engine_types.d.ts +12 -0
- 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 +6 -6
- 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 +2 -0
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/AudioListener.js.map +1 -1
- package/lib/engine-components/AudioSource.js +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 +2 -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 +13 -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.d.ts +5 -1
- package/lib/engine-components/Renderer.js +78 -29
- 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 +8 -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.d.ts +5 -0
- package/lib/engine-components/timeline/PlayableDirector.js +36 -23
- 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.d.ts +9 -0
- package/lib/engine-components/timeline/TimelineTracks.js +112 -19
- 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_constants.ts +1 -1
- 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_instancing.ts +3 -3
- package/src/engine/engine_license.ts +14 -13
- package/src/engine/engine_mainloop_utils.ts +66 -63
- package/src/engine/engine_physics.ts +23 -0
- package/src/engine/engine_setup.ts +21 -8
- package/src/engine/engine_time.ts +9 -4
- package/src/engine/engine_types.ts +36 -22
- package/src/engine-components/Animation.ts +6 -5
- package/src/engine-components/AnimatorController.ts +1 -0
- package/src/engine-components/AudioSource.ts +1 -1
- package/src/engine-components/Camera.ts +14 -12
- package/src/engine-components/Component.ts +5 -2
- package/src/engine-components/Light.ts +20 -13
- package/src/engine-components/ParticleSystem.ts +15 -2
- package/src/engine-components/Renderer.ts +92 -33
- package/src/engine-components/Skybox.ts +49 -22
- package/src/engine-components/Volume.ts +1 -0
- package/src/engine-components/js-extensions/Object3D.ts +8 -2
- package/src/engine-components/timeline/PlayableDirector.ts +35 -24
- package/src/engine-components/timeline/TimelineTracks.ts +124 -20
- 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/engine/codegen/license.js +0 -1
- package/src/tsconfig.json +0 -33
|
@@ -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
|
|
|
@@ -23,13 +23,16 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
|
|
|
23
23
|
|
|
24
24
|
guid: string | undefined;
|
|
25
25
|
|
|
26
|
+
// The actual implementation / prototype of threejs is modified in js-extensions/Object3D
|
|
27
|
+
abstract get transform(): THREE.Object3D;
|
|
28
|
+
|
|
26
29
|
public static isDestroyed(go: THREE.Object3D): boolean {
|
|
27
30
|
return isDestroyed(go);
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
public static setActive(go: THREE.Object3D, active: boolean, processStart: boolean = true
|
|
33
|
+
public static setActive(go: THREE.Object3D, active: boolean, processStart: boolean = true) {
|
|
31
34
|
if (!go) return;
|
|
32
|
-
setActive(go, active
|
|
35
|
+
setActive(go, active);
|
|
33
36
|
main.updateIsActive(go);
|
|
34
37
|
if (active && processStart)
|
|
35
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) {
|
|
@@ -70,7 +70,7 @@ export class ParticleSystemRenderer extends Behaviour {
|
|
|
70
70
|
|
|
71
71
|
getMaterial(trailEnabled: boolean = false) {
|
|
72
72
|
const material = (trailEnabled === true && this.trailMaterial) ? this.trailMaterial : this.particleMaterial;
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
// progressive load on start
|
|
75
75
|
// TODO: figure out how to do this before particle system rendering so we only load textures for visible materials
|
|
76
76
|
if (material && !suppressProgressiveLoading && material["_didRequestTextureLOD"] === undefined) {
|
|
@@ -836,7 +836,20 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
836
836
|
onBeforeRender() {
|
|
837
837
|
this.onUpdate();
|
|
838
838
|
const dt = this.deltaTime;
|
|
839
|
-
|
|
839
|
+
|
|
840
|
+
if (this._batchSystem) {
|
|
841
|
+
// Updating layers on batches
|
|
842
|
+
// TODO: figure out a better way to do this
|
|
843
|
+
// Issue: https://github.com/Alchemist0823/three.quarks/issues/49
|
|
844
|
+
if (this.context.time.frameCount % 60 === 0) {
|
|
845
|
+
for (let i = 0; i < this._batchSystem.batches.length; i++) {
|
|
846
|
+
const batch = this._batchSystem.batches[i];
|
|
847
|
+
batch.layers.disableAll();
|
|
848
|
+
batch.layers.set(2);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
this._batchSystem.update(dt);
|
|
852
|
+
}
|
|
840
853
|
this._time += dt;
|
|
841
854
|
if (this._time > this.duration) this._time = 0;
|
|
842
855
|
}
|
|
@@ -5,7 +5,7 @@ import { RendererLightmap } from "./RendererLightmap";
|
|
|
5
5
|
import { Context, FrameEvent } from "../engine/engine_setup";
|
|
6
6
|
import { getParam } from "../engine/engine_utils";
|
|
7
7
|
import { serializable } from "../engine/engine_serialization_decorator";
|
|
8
|
-
import { AxesHelper, Material, Mesh, Object3D, SkinnedMesh, Texture, Vector4 } from "three";
|
|
8
|
+
import { AxesHelper, Material, Matrix4, Mesh, Object3D, SkinnedMesh, Texture, Vector4 } from "three";
|
|
9
9
|
import { NEEDLE_render_objects } from "../engine/extensions/NEEDLE_render_objects";
|
|
10
10
|
import { NEEDLE_progressive } from "../engine/extensions/NEEDLE_progressive";
|
|
11
11
|
import { NEED_UPDATE_INSTANCE_KEY } from "../engine/engine_instancing";
|
|
@@ -18,6 +18,7 @@ import { showBalloonWarning } from "../engine/debug/debug";
|
|
|
18
18
|
// for staying compatible with old code
|
|
19
19
|
export { InstancingUtil } from "../engine/engine_instancing";
|
|
20
20
|
|
|
21
|
+
const debugRenderer = getParam("debugrenderer");
|
|
21
22
|
const suppressInstancing = getParam("noInstancing");
|
|
22
23
|
const debugLightmap = getParam("debuglightmaps") ? true : false;
|
|
23
24
|
const debugInstancing = getParam("debuginstancing");
|
|
@@ -294,6 +295,7 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
294
295
|
}
|
|
295
296
|
|
|
296
297
|
awake() {
|
|
298
|
+
if (debugRenderer) console.log("Renderer ", this.name, this);
|
|
297
299
|
this.clearInstancingState();
|
|
298
300
|
|
|
299
301
|
if (this.probeAnchor && debug) this.probeAnchor.add(new AxesHelper(.2));
|
|
@@ -332,6 +334,9 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
332
334
|
if (this.renderOrder !== undefined && this.renderOrder.length > 0)
|
|
333
335
|
this.gameObject.renderOrder = this.renderOrder[0];
|
|
334
336
|
}
|
|
337
|
+
else {
|
|
338
|
+
this.context.addBeforeRenderListener(this.gameObject, this.onBeforeRenderThree.bind(this));
|
|
339
|
+
}
|
|
335
340
|
|
|
336
341
|
if (this.lightmapIndex >= 0) {
|
|
337
342
|
// use the override lightmap if its not undefined
|
|
@@ -394,20 +399,14 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
394
399
|
this.handles = undefined;
|
|
395
400
|
this.prevLayers = undefined;
|
|
396
401
|
}
|
|
402
|
+
|
|
397
403
|
setInstancingEnabled(enabled: boolean): boolean {
|
|
398
404
|
if (this._isInstancingEnabled === enabled) return enabled && (this.handles === undefined || this.handles != null && this.handles.length > 0);
|
|
399
405
|
this._isInstancingEnabled = enabled;
|
|
400
406
|
if (enabled) {
|
|
401
|
-
// if handles is undefined we
|
|
402
407
|
if (this.handles === undefined) {
|
|
403
|
-
this.handles = instancing.setup(this.gameObject, this.context, null, { rend: this, foundMeshes: 0 });
|
|
408
|
+
this.handles = instancing.setup(this, this.gameObject, this.context, null, { rend: this, foundMeshes: 0, useMatrixWorldAutoUpdate: this.useInstanceMatrixWorldAutoUpdate() });
|
|
404
409
|
if (this.handles) {
|
|
405
|
-
// const disableSelf = this.gameObject.type === "Mesh" || this.gameObject.children?.length === this.handles.length;
|
|
406
|
-
// this.gameObject.visible = !disableSelf;
|
|
407
|
-
// this.gameObject.type = "Object3D";
|
|
408
|
-
// this.gameObject.material = null;
|
|
409
|
-
// console.log("Using instancing", this.gameObject.visible);
|
|
410
|
-
// this.gameObject.onBeforeRender = () => console.log("SHOULD NOT BE CALLED");
|
|
411
410
|
GameObject.markAsInstancedRendered(this.gameObject, true);
|
|
412
411
|
return true;
|
|
413
412
|
}
|
|
@@ -417,8 +416,6 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
417
416
|
handler.updateInstanceMatrix(true);
|
|
418
417
|
handler.add();
|
|
419
418
|
}
|
|
420
|
-
// this.gameObject.type = "Object3D";
|
|
421
|
-
// this.gameObject.visible = false;
|
|
422
419
|
GameObject.markAsInstancedRendered(this.gameObject, true);
|
|
423
420
|
return true;
|
|
424
421
|
}
|
|
@@ -429,13 +426,19 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
429
426
|
handler.remove();
|
|
430
427
|
}
|
|
431
428
|
}
|
|
432
|
-
// this.gameObject.visible = true;
|
|
433
429
|
return true;
|
|
434
430
|
}
|
|
435
431
|
|
|
436
432
|
return false;
|
|
437
433
|
}
|
|
438
434
|
|
|
435
|
+
/** Return true to wrap matrix update events for instanced rendering to update instance matrices automatically when matrixWorld changes
|
|
436
|
+
* This is a separate method to be overrideable from user code
|
|
437
|
+
*/
|
|
438
|
+
useInstanceMatrixWorldAutoUpdate() {
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
|
|
439
442
|
start() {
|
|
440
443
|
if (this.enableInstancing && !suppressInstancing) {
|
|
441
444
|
this.setInstancingEnabled(true);
|
|
@@ -461,6 +464,7 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
461
464
|
}
|
|
462
465
|
|
|
463
466
|
this.updateReflectionProbe();
|
|
467
|
+
|
|
464
468
|
}
|
|
465
469
|
|
|
466
470
|
onDisable() {
|
|
@@ -479,17 +483,12 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
479
483
|
NEEDLE_render_objects.applyStencil(this);
|
|
480
484
|
}
|
|
481
485
|
|
|
482
|
-
static envmap: THREE.Texture | null = null;
|
|
483
486
|
|
|
484
487
|
onBeforeRender() {
|
|
485
488
|
if (!this.gameObject) {
|
|
486
489
|
return;
|
|
487
490
|
}
|
|
488
491
|
|
|
489
|
-
Renderer.envmap = this.scene.environment;
|
|
490
|
-
|
|
491
|
-
const needsUpdate: boolean = this.gameObject[NEED_UPDATE_INSTANCE_KEY] === true || this.gameObject.matrixWorldNeedsUpdate;
|
|
492
|
-
|
|
493
492
|
if (this.isMultiMaterialObject(this.gameObject) && this.gameObject.children?.length > 0) {
|
|
494
493
|
for (const ch of this.gameObject.children) {
|
|
495
494
|
this.applySettings(ch);
|
|
@@ -499,9 +498,14 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
499
498
|
this.applySettings(this.gameObject);
|
|
500
499
|
}
|
|
501
500
|
|
|
502
|
-
if (
|
|
503
|
-
|
|
504
|
-
|
|
501
|
+
if (this.handles?.length) {
|
|
502
|
+
// if (this.name === "Darbouka")
|
|
503
|
+
// console.log(this.name, this.gameObject.matrixWorldNeedsUpdate);
|
|
504
|
+
const needsUpdate: boolean = this.gameObject[NEED_UPDATE_INSTANCE_KEY] === true;// || this.gameObject.matrixWorldNeedsUpdate;
|
|
505
|
+
if (needsUpdate) {
|
|
506
|
+
if(debugInstancing)
|
|
507
|
+
console.log("UPDATE INSTANCED MATRICES", this.context.time.frame);
|
|
508
|
+
this.gameObject[NEED_UPDATE_INSTANCE_KEY] = false;
|
|
505
509
|
const remove = false;// Math.random() < .01;
|
|
506
510
|
for (let i = this.handles.length - 1; i >= 0; i--) {
|
|
507
511
|
const h = this.handles[i];
|
|
@@ -539,14 +543,7 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
539
543
|
|
|
540
544
|
onBeforeRenderThree(_renderer, _scene, _camera, _geometry, material, _group) {
|
|
541
545
|
|
|
542
|
-
|
|
543
|
-
if (!suppressProgressiveLoading && material._didRequestTextureLOD === undefined && this.allowProgressiveLoading) {
|
|
544
|
-
material._didRequestTextureLOD = 0;
|
|
545
|
-
if (debugProgressiveLoading) {
|
|
546
|
-
console.log("Load material LOD", material.name);
|
|
547
|
-
}
|
|
548
|
-
NEEDLE_progressive.assignTextureLOD(this.context, this.sourceId, material);
|
|
549
|
-
}
|
|
546
|
+
this.loadProgressiveTextures(material);
|
|
550
547
|
|
|
551
548
|
if (material.envMapIntensity !== undefined) {
|
|
552
549
|
const factor = this.hasLightmap ? Math.PI : 1;
|
|
@@ -607,6 +604,22 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
607
604
|
}
|
|
608
605
|
}
|
|
609
606
|
|
|
607
|
+
loadProgressiveTextures(material: THREE.Material) {
|
|
608
|
+
// progressive load before rendering so we only load textures for visible materials
|
|
609
|
+
if (!suppressProgressiveLoading && material) {
|
|
610
|
+
if (debugProgressiveLoading && material["_didRequestTextureLOD"] === undefined)
|
|
611
|
+
console.warn("Progressive?", this)
|
|
612
|
+
|
|
613
|
+
if (material["_didRequestTextureLOD"] === undefined && this.allowProgressiveLoading) {
|
|
614
|
+
material["_didRequestTextureLOD"] = 0;
|
|
615
|
+
if (debugProgressiveLoading) {
|
|
616
|
+
console.log("Load material LOD", material.name);
|
|
617
|
+
}
|
|
618
|
+
NEEDLE_progressive.assignTextureLOD(this.context, this.sourceId, material);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
610
623
|
private applySettings(go: THREE.Object3D) {
|
|
611
624
|
go.receiveShadow = this.receiveShadows;
|
|
612
625
|
if (this.shadowCastingMode == ShadowCastingMode.On) {
|
|
@@ -689,17 +702,22 @@ export enum ShadowCastingMode {
|
|
|
689
702
|
|
|
690
703
|
|
|
691
704
|
|
|
692
|
-
declare class InstancingSetupArgs {
|
|
705
|
+
declare class InstancingSetupArgs {
|
|
706
|
+
rend: Renderer;
|
|
707
|
+
foundMeshes: number;
|
|
708
|
+
useMatrixWorldAutoUpdate: boolean;
|
|
709
|
+
};
|
|
693
710
|
|
|
694
711
|
class InstancingHandler {
|
|
695
712
|
|
|
696
713
|
public objs: InstancedMeshRenderer[] = [];
|
|
697
714
|
|
|
698
|
-
public setup(obj: THREE.Object3D, context: Context, handlesArray: InstanceHandle[] | null, args: InstancingSetupArgs, level: number = 0)
|
|
715
|
+
public setup(renderer:Renderer, obj: THREE.Object3D, context: Context, handlesArray: InstanceHandle[] | null, args: InstancingSetupArgs, level: number = 0)
|
|
699
716
|
: InstanceHandle[] | null {
|
|
700
717
|
|
|
701
718
|
const res = this.tryCreateOrAddInstance(obj, context, args);
|
|
702
719
|
if (res) {
|
|
720
|
+
renderer.loadProgressiveTextures(res.instancer.material);
|
|
703
721
|
if (handlesArray === null) handlesArray = [];
|
|
704
722
|
handlesArray.push(res);
|
|
705
723
|
return handlesArray;
|
|
@@ -708,7 +726,7 @@ class InstancingHandler {
|
|
|
708
726
|
if (level <= 0 && obj.type !== "Mesh") {
|
|
709
727
|
const nextLevel = level + 1;
|
|
710
728
|
for (const ch of obj.children) {
|
|
711
|
-
handlesArray = this.setup(ch, context, handlesArray, args, nextLevel);
|
|
729
|
+
handlesArray = this.setup(renderer, ch, context, handlesArray, args, nextLevel);
|
|
712
730
|
}
|
|
713
731
|
}
|
|
714
732
|
return handlesArray;
|
|
@@ -736,16 +754,52 @@ class InstancingHandler {
|
|
|
736
754
|
for (const i of this.objs) {
|
|
737
755
|
if (i.isFull()) continue;
|
|
738
756
|
if (i.geo === geo && i.material === mat) {
|
|
739
|
-
|
|
757
|
+
const handle = i.addInstance(mesh);
|
|
758
|
+
if (args.useMatrixWorldAutoUpdate && handle)
|
|
759
|
+
this.autoUpdateInstanceMatrix(mesh, i, handle);
|
|
760
|
+
return handle;
|
|
740
761
|
}
|
|
741
762
|
}
|
|
742
763
|
// console.log("Add new instance mesh renderer", obj);
|
|
743
764
|
const i = new InstancedMeshRenderer(obj.name, geo, mat, 200, context);
|
|
744
765
|
this.objs.push(i);
|
|
745
|
-
|
|
766
|
+
const handle = i.addInstance(mesh);
|
|
767
|
+
if (args.useMatrixWorldAutoUpdate && handle)
|
|
768
|
+
this.autoUpdateInstanceMatrix(mesh, i, handle);
|
|
769
|
+
return handle;
|
|
746
770
|
}
|
|
747
771
|
return null;
|
|
748
772
|
}
|
|
773
|
+
|
|
774
|
+
private autoUpdateInstanceMatrix(obj: Object3D, _renderer: InstancedMeshRenderer, _handle: InstanceHandle) {
|
|
775
|
+
const original = obj.matrixWorld["multiplyMatrices"].bind(obj.matrixWorld);
|
|
776
|
+
let previousMatrix: THREE.Matrix4 = obj.matrixWorld.clone();
|
|
777
|
+
|
|
778
|
+
const matrixChangeWrapper = (a: Matrix4, b: Matrix4) => {
|
|
779
|
+
const newMatrixWorld = original(a, b);
|
|
780
|
+
// console.warn("MULT", obj.matrixWorldNeedsUpdate);
|
|
781
|
+
if (obj[NEED_UPDATE_INSTANCE_KEY] || previousMatrix.equals(newMatrixWorld) === false) {
|
|
782
|
+
previousMatrix.copy(newMatrixWorld)
|
|
783
|
+
// handle.setMatrix(newMatrixWorld);
|
|
784
|
+
obj[NEED_UPDATE_INSTANCE_KEY] = true;
|
|
785
|
+
}
|
|
786
|
+
return newMatrixWorld;
|
|
787
|
+
};
|
|
788
|
+
obj.matrixWorld["multiplyMatrices"] = matrixChangeWrapper;
|
|
789
|
+
|
|
790
|
+
// wrap matrixWorldNeedsUpdate
|
|
791
|
+
// let originalMatrixWorldNeedsUpdate = obj.matrixWorldNeedsUpdate;
|
|
792
|
+
// Object.defineProperty(obj, "matrixWorldNeedsUpdate", {
|
|
793
|
+
// get: () => {
|
|
794
|
+
// return originalMatrixWorldNeedsUpdate;
|
|
795
|
+
// },
|
|
796
|
+
// set: (value: boolean) => {
|
|
797
|
+
// if(value) console.warn("SET MATRIX WORLD NEEDS UPDATE");
|
|
798
|
+
// originalMatrixWorldNeedsUpdate = value;
|
|
799
|
+
// }
|
|
800
|
+
// });
|
|
801
|
+
|
|
802
|
+
}
|
|
749
803
|
}
|
|
750
804
|
const instancing: InstancingHandler = new InstancingHandler();
|
|
751
805
|
|
|
@@ -773,6 +827,11 @@ class InstanceHandle {
|
|
|
773
827
|
this.instancer.updateInstance(this.object.matrixWorld, this.instanceIndex);
|
|
774
828
|
}
|
|
775
829
|
|
|
830
|
+
setMatrix(matrix: THREE.Matrix4) {
|
|
831
|
+
if (this.instanceIndex < 0) return;
|
|
832
|
+
this.instancer.updateInstance(matrix, this.instanceIndex);
|
|
833
|
+
}
|
|
834
|
+
|
|
776
835
|
add() {
|
|
777
836
|
if (this.instanceIndex >= 0) return;
|
|
778
837
|
this.instancer.add(this);
|
|
@@ -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
|
}
|
|
@@ -12,7 +12,6 @@ export function apply(object: Object3D) {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
Object3D.prototype["SetActive"] = function (active: boolean) {
|
|
17
16
|
this.visible = active;
|
|
18
17
|
}
|
|
@@ -64,11 +63,18 @@ if (!Object.getOwnPropertyDescriptor(Object3D.prototype, "activeSelf")) {
|
|
|
64
63
|
return isActiveSelf(this)
|
|
65
64
|
},
|
|
66
65
|
set: function (val: boolean | number) {
|
|
67
|
-
setActive(this, val
|
|
66
|
+
setActive(this, val);
|
|
68
67
|
}
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
70
|
|
|
71
|
+
if (!Object.getOwnPropertyDescriptor(Object3D.prototype, "transform")) {
|
|
72
|
+
Object.defineProperty(Object3D.prototype, "transform", {
|
|
73
|
+
get: function () {
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
72
78
|
|
|
73
79
|
|
|
74
80
|
|