@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
|
@@ -8,11 +8,26 @@ import { NEEDLE_gameobject_data } from "./NEEDLE_gameobject_data";
|
|
|
8
8
|
import { NEEDLE_persistent_assets } from "./NEEDLE_persistent_assets";
|
|
9
9
|
// import { KHR_animation_pointer } from "./KHR_animation_pointer";
|
|
10
10
|
import { NEEDLE_lightmaps } from "../extensions/NEEDLE_lightmaps";
|
|
11
|
-
import { SourceIdentifier } from "../engine_types";
|
|
11
|
+
import { Constructor, ConstructorConcrete, SourceIdentifier } from "../engine_types";
|
|
12
12
|
import { Context } from "../engine_setup";
|
|
13
13
|
import { NEEDLE_lighting_settings } from "./NEEDLE_lighting_settings";
|
|
14
14
|
import { NEEDLE_render_objects } from "./NEEDLE_render_objects";
|
|
15
15
|
import { NEEDLE_progressive } from "./NEEDLE_progressive";
|
|
16
|
+
import { InternalUsageTrackerPlugin } from "./usage_tracker";
|
|
17
|
+
import { isUsageTrackingEnabled } from "../engine_assetdatabase";
|
|
18
|
+
import { GLTFLoaderPlugin } from "three/examples/jsm/loaders/GLTFLoader";
|
|
19
|
+
|
|
20
|
+
const _addedCustomExtension = new Array<ConstructorConcrete<GLTFLoaderPlugin>>();
|
|
21
|
+
|
|
22
|
+
export function addCustomExtension(ext: ConstructorConcrete<GLTFLoaderPlugin>) {
|
|
23
|
+
if (!_addedCustomExtension.includes(ext))
|
|
24
|
+
_addedCustomExtension.push(ext);
|
|
25
|
+
}
|
|
26
|
+
export function removeCustomExtension(ext: ConstructorConcrete<GLTFLoaderPlugin>) {
|
|
27
|
+
const index = _addedCustomExtension.indexOf(ext);
|
|
28
|
+
if (index >= 0)
|
|
29
|
+
_addedCustomExtension.splice(index, 1);
|
|
30
|
+
}
|
|
16
31
|
|
|
17
32
|
export function registerComponentExtension(loader: GLTFLoader): NEEDLE_components {
|
|
18
33
|
const ext = new NEEDLE_components();
|
|
@@ -23,6 +38,8 @@ export function registerComponentExtension(loader: GLTFLoader): NEEDLE_component
|
|
|
23
38
|
return ext;
|
|
24
39
|
}
|
|
25
40
|
|
|
41
|
+
|
|
42
|
+
|
|
26
43
|
class PointerResolver {
|
|
27
44
|
resolvePath(path: string) {
|
|
28
45
|
if (path.includes('/extensions/builtin_components/'))
|
|
@@ -42,6 +59,10 @@ export function registerExtensions(loader: GLTFLoader, context: Context, sourceI
|
|
|
42
59
|
loader.register(p => new NEEDLE_render_objects(p, sourceId));
|
|
43
60
|
loader.register(p => new NEEDLE_progressive(p, sourceId, context));
|
|
44
61
|
loader.register(p => new EXT_texture_exr(p));
|
|
62
|
+
if (isUsageTrackingEnabled()) loader.register(p => new InternalUsageTrackerPlugin(p))
|
|
63
|
+
|
|
64
|
+
for (const ext of _addedCustomExtension)
|
|
65
|
+
loader.register(p => new ext(p));
|
|
45
66
|
|
|
46
67
|
const setPointerResolverFunction = loader["setAnimationPointerResolver"];
|
|
47
68
|
if (typeof setPointerResolverFunction === "function")
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
|
|
2
|
+
import { GLTF, GLTFLoaderPlugin, GLTFParser } from "three/examples/jsm/loaders/GLTFLoader";
|
|
3
|
+
import { Group, Mesh, Object3D, SkinnedMesh } from "three";
|
|
4
|
+
import { getParam } from "../engine_utils";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const $loadingId = Symbol("gltf-loader-internal-usage-tracker");
|
|
8
|
+
const debug = getParam("debugusers");
|
|
9
|
+
|
|
10
|
+
export class InternalUsageTrackerPlugin implements GLTFLoaderPlugin {
|
|
11
|
+
|
|
12
|
+
static isLoading(object: object) {
|
|
13
|
+
return InternalUsageTrackerPlugin._loadingProcesses > 0;
|
|
14
|
+
return object[$loadingId] !== undefined;
|
|
15
|
+
}
|
|
16
|
+
private static _loadingProcesses = 0;
|
|
17
|
+
|
|
18
|
+
private readonly parser: GLTFParser;
|
|
19
|
+
private readonly _getDependency: any;
|
|
20
|
+
private readonly _loadingId: string;
|
|
21
|
+
private _loadedObjects: Set<object> = new Set();
|
|
22
|
+
|
|
23
|
+
constructor(parser: GLTFParser) {
|
|
24
|
+
this.parser = parser;
|
|
25
|
+
this._getDependency = this.parser.getDependency;
|
|
26
|
+
this._loadingId = Date.now().toString()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
beforeRoot() {
|
|
30
|
+
InternalUsageTrackerPlugin._loadingProcesses++;
|
|
31
|
+
const self = this;
|
|
32
|
+
// Patch parser get dependency to track all objects that have been loaded or created
|
|
33
|
+
const getDependency = this._getDependency;
|
|
34
|
+
this.parser.getDependency = function (type: string, index: number) {
|
|
35
|
+
const promise = getDependency.call(this, type, index);
|
|
36
|
+
promise.then((result) => {
|
|
37
|
+
if (result) {
|
|
38
|
+
self._loadedObjects.add(result);
|
|
39
|
+
result[$loadingId] = self._loadingId;
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
});
|
|
43
|
+
return promise;
|
|
44
|
+
};
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
afterRoot(_result: GLTF) {
|
|
49
|
+
InternalUsageTrackerPlugin._loadingProcesses--;
|
|
50
|
+
// reset original method
|
|
51
|
+
this.parser.getDependency = this._getDependency;
|
|
52
|
+
|
|
53
|
+
// Cleanup usage of objects that have not been used in a scene
|
|
54
|
+
for (const loaded of this._loadedObjects) {
|
|
55
|
+
delete loaded[$loadingId];
|
|
56
|
+
|
|
57
|
+
if (loaded instanceof Object3D) {
|
|
58
|
+
if (!loaded.parent) {
|
|
59
|
+
if (loaded instanceof Mesh) {
|
|
60
|
+
if (debug) console.warn("> GLTF LOADER: Mesh not used in scene!", loaded);
|
|
61
|
+
loaded.material = null;
|
|
62
|
+
loaded.geometry = null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
// private readonly _creatingNodeMesh: Map<number, CreateNodeMesh> = new Map();
|
|
75
|
+
|
|
76
|
+
// createNodeMesh(_nodeIndex: number): CreateNodeMesh | null {
|
|
77
|
+
// // if (!this.parser) return null;
|
|
78
|
+
// // let process = this._creatingNodeMesh.get(nodeIndex);
|
|
79
|
+
// // if (process) return process;
|
|
80
|
+
|
|
81
|
+
// // process = this.parser.createNodeMesh(nodeIndex)?.then((mesh) => {
|
|
82
|
+
// // console.log("createNodeMesh", nodeIndex, mesh);
|
|
83
|
+
// // return mesh;
|
|
84
|
+
// // }) as CreateNodeMesh;
|
|
85
|
+
// // this._creatingNodeMesh.set(nodeIndex, process);
|
|
86
|
+
// // return process;
|
|
87
|
+
// }
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
@@ -73,7 +73,6 @@ export class Animator extends Behaviour {
|
|
|
73
73
|
/**@deprecated use getBool */
|
|
74
74
|
GetBool(name: string | number) { return this.getBool(name); }
|
|
75
75
|
getBool(name: string | number): boolean {
|
|
76
|
-
console.log("name", name);
|
|
77
76
|
return this.runtimeAnimatorController?.getBool(name) ?? false;
|
|
78
77
|
}
|
|
79
78
|
|
|
@@ -768,6 +768,7 @@ class RootMotionAction {
|
|
|
768
768
|
}
|
|
769
769
|
|
|
770
770
|
onAfterUpdate() {
|
|
771
|
+
if (!this.action) return;
|
|
771
772
|
const weight = this.action.getEffectiveWeight();
|
|
772
773
|
this.positionChange.multiplyScalar(weight);
|
|
773
774
|
this.rotationChange.slerp(RootMotionAction.identityQuaternion, 1 - weight);
|
|
@@ -836,6 +837,7 @@ class RootMotionHandler {
|
|
|
836
837
|
|
|
837
838
|
private findRootTrack(clip: AnimationClip, name: string) {
|
|
838
839
|
const tracks = clip.tracks;
|
|
840
|
+
if (!tracks) return null;
|
|
839
841
|
for (const track of tracks) {
|
|
840
842
|
if (track.name.endsWith(name)) {
|
|
841
843
|
// if (track.name.includes("Hips"))
|
|
@@ -65,7 +65,7 @@ export class AudioSource extends Behaviour {
|
|
|
65
65
|
if (fn == undefined) return;
|
|
66
66
|
if (AudioSource._userInteractionRegistered) return;
|
|
67
67
|
AudioSource._userInteractionRegistered = true;
|
|
68
|
-
console.log("registered interaction, can play audio now");
|
|
68
|
+
if(debug) console.log("🔊 registered interaction, can play audio now");
|
|
69
69
|
document.removeEventListener('pointerdown', fn);
|
|
70
70
|
document.removeEventListener('click', fn);
|
|
71
71
|
document.removeEventListener('dragstart', fn);
|
|
@@ -5,11 +5,12 @@ import { RGBAColor } from "./js-extensions/RGBAColor";
|
|
|
5
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
|
-
import { getWorldPosition } from "../engine/engine_three_utils";
|
|
8
|
+
import { getWorldPosition, Graphics } from "../engine/engine_three_utils";
|
|
9
9
|
import { Gizmos } from "../engine/engine_gizmos";
|
|
10
10
|
|
|
11
11
|
import { EquirectangularReflectionMapping, OrthographicCamera, PerspectiveCamera, Ray, sRGBEncoding, Vector3 } from "three";
|
|
12
12
|
import { OrbitControls } from "./OrbitControls";
|
|
13
|
+
import { RenderTexture } from "../engine/engine_texture";
|
|
13
14
|
|
|
14
15
|
export enum ClearFlags {
|
|
15
16
|
Skybox = 1,
|
|
@@ -151,6 +152,15 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
151
152
|
this.applyClearFlagsIfIsActiveCamera();
|
|
152
153
|
}
|
|
153
154
|
|
|
155
|
+
@serializable(RenderTexture)
|
|
156
|
+
public set targetTexture(rt: RenderTexture | null) {
|
|
157
|
+
this._targetTexture = rt;
|
|
158
|
+
}
|
|
159
|
+
public get targetTexture(): RenderTexture | null {
|
|
160
|
+
return this._targetTexture;
|
|
161
|
+
}
|
|
162
|
+
private _targetTexture: RenderTexture | null = null;
|
|
163
|
+
|
|
154
164
|
private _backgroundColor?: RGBAColor;
|
|
155
165
|
private _fov?: number;
|
|
156
166
|
private _cam: THREE.PerspectiveCamera | THREE.OrthographicCamera | null = null;
|
|
@@ -217,6 +227,28 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
217
227
|
this.context.removeCamera(this);
|
|
218
228
|
}
|
|
219
229
|
|
|
230
|
+
onBeforeRender() {
|
|
231
|
+
if (this._cam) {
|
|
232
|
+
if (this._targetTexture) {
|
|
233
|
+
if (this.context.isManagedExternally) {
|
|
234
|
+
// TODO: rendering with r3f renderer does throw an shader error for some reason?
|
|
235
|
+
if (!this["_warnedAboutExternalRenderer"]) {
|
|
236
|
+
this["_warnedAboutExternalRenderer"] = true;
|
|
237
|
+
console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: " + this.name, this.targetTexture)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// TODO: optimize to not render twice if this is already the main camera. In that case we just want to blit
|
|
242
|
+
const composer = this.context.composer;
|
|
243
|
+
const useNormalRenderer = true;// this.context.isInXR || !composer;
|
|
244
|
+
const renderer = useNormalRenderer ? this.context.renderer : composer;
|
|
245
|
+
if (renderer) {
|
|
246
|
+
this._targetTexture.render(this.context.scene, this._cam, renderer)
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
220
252
|
buildCamera() {
|
|
221
253
|
if (this._cam) return;
|
|
222
254
|
|
|
@@ -262,43 +294,51 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
262
294
|
}
|
|
263
295
|
|
|
264
296
|
applyClearFlagsIfIsActiveCamera() {
|
|
297
|
+
if (this.context.mainCameraComponent === this) {
|
|
298
|
+
this.applyClearFlags();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
applyClearFlags() {
|
|
303
|
+
if (!this._cam) {
|
|
304
|
+
if (debug) console.log("Camera does not exist (apply clear flags)")
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
265
307
|
if (debug)
|
|
266
|
-
showBalloonMessage("apply Camera clear flags");
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (
|
|
271
|
-
if (!this.ARBackgroundAlpha || this.ARBackgroundAlpha < 0.001) {
|
|
272
|
-
this.context.scene.background = null;
|
|
273
|
-
this.context.renderer.setClearColor(0x000000, 0);
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
this.enableSkybox();
|
|
278
|
-
|
|
279
|
-
if (this._backgroundBlurriness !== undefined)
|
|
280
|
-
this.context.scene.backgroundBlurriness = this._backgroundBlurriness;
|
|
281
|
-
if (this._backgroundIntensity !== undefined)
|
|
282
|
-
//@ts-ignore
|
|
283
|
-
this.context.scene.backgroundIntensity = this._backgroundIntensity;
|
|
284
|
-
|
|
285
|
-
break;
|
|
286
|
-
case ClearFlags.SolidColor:
|
|
287
|
-
if (this._backgroundColor) {
|
|
288
|
-
let alpha = this._backgroundColor.alpha;
|
|
289
|
-
// when in WebXR use ar background alpha override or set to 0
|
|
290
|
-
if (Camera.backgroundShouldBeTransparent(this.context)) {
|
|
291
|
-
alpha = this.ARBackgroundAlpha ?? 0;
|
|
292
|
-
}
|
|
308
|
+
showBalloonMessage("apply Camera clear flags: " + this._clearFlags);
|
|
309
|
+
switch (this._clearFlags) {
|
|
310
|
+
case ClearFlags.Skybox:
|
|
311
|
+
if (Camera.backgroundShouldBeTransparent(this.context)) {
|
|
312
|
+
if (!this.ARBackgroundAlpha || this.ARBackgroundAlpha < 0.001) {
|
|
293
313
|
this.context.scene.background = null;
|
|
294
|
-
this.context.renderer.setClearColor(
|
|
314
|
+
this.context.renderer.setClearColor(0x000000, 0);
|
|
315
|
+
return;
|
|
295
316
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
317
|
+
}
|
|
318
|
+
this.enableSkybox();
|
|
319
|
+
|
|
320
|
+
if (this._backgroundBlurriness !== undefined)
|
|
321
|
+
this.context.scene.backgroundBlurriness = this._backgroundBlurriness;
|
|
322
|
+
if (this._backgroundIntensity !== undefined)
|
|
323
|
+
//@ts-ignore
|
|
324
|
+
this.context.scene.backgroundIntensity = this._backgroundIntensity;
|
|
325
|
+
|
|
326
|
+
break;
|
|
327
|
+
case ClearFlags.SolidColor:
|
|
328
|
+
if (this._backgroundColor) {
|
|
329
|
+
let alpha = this._backgroundColor.alpha;
|
|
330
|
+
// when in WebXR use ar background alpha override or set to 0
|
|
331
|
+
if (Camera.backgroundShouldBeTransparent(this.context)) {
|
|
332
|
+
alpha = this.ARBackgroundAlpha ?? 0;
|
|
333
|
+
}
|
|
334
|
+
this.context.scene.background = null;
|
|
335
|
+
this.context.renderer.setClearColor(this._backgroundColor, alpha);
|
|
336
|
+
}
|
|
337
|
+
break;
|
|
338
|
+
case ClearFlags.Uninitialized:
|
|
339
|
+
this.context.scene.background = null
|
|
340
|
+
this.context.renderer.setClearColor(0x000000, 0);
|
|
341
|
+
break;
|
|
302
342
|
}
|
|
303
343
|
}
|
|
304
344
|
|
|
@@ -309,7 +349,7 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
309
349
|
}
|
|
310
350
|
|
|
311
351
|
/** Returns true when in XR on a pass through device where the background shouldbe invisible */
|
|
312
|
-
static backgroundShouldBeTransparent(context:Context) {
|
|
352
|
+
static backgroundShouldBeTransparent(context: Context) {
|
|
313
353
|
const session = context.renderer.xr?.getSession();
|
|
314
354
|
if (!session) return false;
|
|
315
355
|
const environmentBlendMode = session.environmentBlendMode;
|
|
@@ -330,7 +370,7 @@ export class Camera extends Behaviour implements ICamera {
|
|
|
330
370
|
}
|
|
331
371
|
}
|
|
332
372
|
}
|
|
333
|
-
|
|
373
|
+
|
|
334
374
|
return transparent;
|
|
335
375
|
}
|
|
336
376
|
}
|
|
@@ -86,6 +86,9 @@ export class CharacterControllerInput extends Behaviour {
|
|
|
86
86
|
@serializable()
|
|
87
87
|
jumpForce: number = 1;
|
|
88
88
|
|
|
89
|
+
@serializable()
|
|
90
|
+
doubleJumpForce: number = 2;
|
|
91
|
+
|
|
89
92
|
@serializable(Animator)
|
|
90
93
|
animator?: Animator;
|
|
91
94
|
|
|
@@ -106,7 +109,7 @@ export class CharacterControllerInput extends Behaviour {
|
|
|
106
109
|
|
|
107
110
|
if (this.controller?.isGrounded) {
|
|
108
111
|
this._jumpCount = 0;
|
|
109
|
-
this.animator?.
|
|
112
|
+
if (this.doubleJumpForce > 0) this.animator?.setBool("doubleJump", false);
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
const forward = this.context.input.isKeyPressed("w");
|
|
@@ -121,8 +124,8 @@ export class CharacterControllerInput extends Behaviour {
|
|
|
121
124
|
this._currentSpeed.z += step * this.movementSpeed * this.context.time.deltaTime;
|
|
122
125
|
|
|
123
126
|
// if (!this.controller || this.controller.isGrounded)
|
|
124
|
-
this.animator?.
|
|
125
|
-
this.animator?.
|
|
127
|
+
this.animator?.setBool("running", step != 0);
|
|
128
|
+
this.animator?.setBool("jumping", this.controller?.isGrounded === true && jump);
|
|
126
129
|
|
|
127
130
|
this._temp.copy(this._currentSpeed);
|
|
128
131
|
this._temp.applyQuaternion(this.gameObject.quaternion);
|
|
@@ -146,9 +149,9 @@ export class CharacterControllerInput extends Behaviour {
|
|
|
146
149
|
|
|
147
150
|
if (this.controller && jump && this.jumpForce > 0) {
|
|
148
151
|
let canJump = this.controller?.isGrounded;
|
|
149
|
-
if (!this.controller?.isGrounded && this._jumpCount === 1) {
|
|
152
|
+
if (this.doubleJumpForce > 0 && !this.controller?.isGrounded && this._jumpCount === 1) {
|
|
150
153
|
canJump = true;
|
|
151
|
-
this.animator?.
|
|
154
|
+
this.animator?.setBool("doubleJump", true);
|
|
152
155
|
}
|
|
153
156
|
|
|
154
157
|
if (canJump) {
|
|
@@ -156,8 +159,8 @@ export class CharacterControllerInput extends Behaviour {
|
|
|
156
159
|
// TODO: factor in mass
|
|
157
160
|
const rb = this.controller.rigidbody;
|
|
158
161
|
// const fullJumpHoldLength = .1;
|
|
159
|
-
const factor = this._jumpCount === 2 ?
|
|
160
|
-
rb.applyImpulse(new Vector3(0, 1, 0).multiplyScalar(
|
|
162
|
+
const factor = this._jumpCount === 2 ? this.doubleJumpForce : this.jumpForce;// Mathf.clamp((this.context.time.time - this._jumpDownTime), 0, fullJumpHoldLength) / fullJumpHoldLength;
|
|
163
|
+
rb.applyImpulse(new Vector3(0, 1, 0).multiplyScalar(factor));
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
166
|
|
|
@@ -174,10 +177,10 @@ export class CharacterControllerInput extends Behaviour {
|
|
|
174
177
|
const hits = this.context.physics.raycast(this._raycastOptions);
|
|
175
178
|
this.gameObject.layers.set(currentLayer);
|
|
176
179
|
if ((hits.length && hits[0].distance > 2 || verticalSpeed < -10)) {
|
|
177
|
-
this.animator?.
|
|
180
|
+
this.animator?.setBool("falling", true);
|
|
178
181
|
}
|
|
179
182
|
}
|
|
180
|
-
else this.animator?.
|
|
183
|
+
else this.animator?.setBool("falling", false);
|
|
181
184
|
}
|
|
182
185
|
}
|
|
183
186
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Behaviour } from "./Component";
|
|
2
2
|
import { Rigidbody } from "./RigidBody";
|
|
3
3
|
import { serializable } from "../engine/engine_serialization_decorator";
|
|
4
|
-
import { Event, Mesh, Object3D, Vector3 } from "three"
|
|
4
|
+
import { Event, Group, Mesh, Object3D, Vector3 } from "three"
|
|
5
5
|
// import { IColliderProvider, registerColliderProvider } from "../engine/engine_physics";
|
|
6
6
|
import { ICollider } from "../engine/engine_types";
|
|
7
7
|
import { getWorldScale } from "../engine/engine_three_utils";
|
|
@@ -77,6 +77,7 @@ export class MeshCollider extends Collider {
|
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
sharedMesh?: Mesh;
|
|
80
|
+
|
|
80
81
|
@serializable()
|
|
81
82
|
convex: boolean = false;
|
|
82
83
|
|
|
@@ -88,8 +89,21 @@ export class MeshCollider extends Collider {
|
|
|
88
89
|
this.sharedMesh = this.gameObject;
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
|
-
if (this.sharedMesh?.isMesh)
|
|
92
|
+
if (this.sharedMesh?.isMesh) {
|
|
92
93
|
this.context.physics.addMeshCollider(this, this.sharedMesh, this.convex, getWorldScale(this.gameObject));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const group = this.sharedMesh as any as Group;
|
|
97
|
+
if (group?.isGroup) {
|
|
98
|
+
console.warn(`MeshCollider mesh is a group \"${this.sharedMesh?.name}\", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`, this)
|
|
99
|
+
for (const ch in group.children) {
|
|
100
|
+
const child = group.children[ch] as Mesh;
|
|
101
|
+
if (child.isMesh) {
|
|
102
|
+
this.context.physics.addMeshCollider(this, child, this.convex, getWorldScale(this.gameObject));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
93
107
|
}
|
|
94
108
|
}
|
|
95
109
|
|