@needle-tools/engine 2.60.3-pre → 2.61.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/needle-engine.js +2916 -2907
  3. package/dist/needle-engine.umd.cjs +65 -65
  4. package/lib/engine-components/AnimatorController.js +1 -2
  5. package/lib/engine-components/AnimatorController.js.map +1 -1
  6. package/lib/engine-components/Light.js +3 -1
  7. package/lib/engine-components/Light.js.map +1 -1
  8. package/lib/engine-components/ParticleSystem.d.ts +1 -0
  9. package/lib/engine-components/ParticleSystem.js +20 -3
  10. package/lib/engine-components/ParticleSystem.js.map +1 -1
  11. package/lib/engine-components/Renderer.js.map +1 -1
  12. package/lib/engine-components/WebXR.d.ts +1 -0
  13. package/lib/engine-components/WebXR.js +7 -0
  14. package/lib/engine-components/WebXR.js.map +1 -1
  15. package/lib/engine-components/ui/BaseUIComponent.js +1 -1
  16. package/lib/engine-components/ui/BaseUIComponent.js.map +1 -1
  17. package/lib/engine-components/ui/Canvas.d.ts +1 -0
  18. package/lib/engine-components/ui/Canvas.js +5 -0
  19. package/lib/engine-components/ui/Canvas.js.map +1 -1
  20. package/lib/engine-components/ui/Text.js +1 -1
  21. package/lib/engine-components/ui/Text.js.map +1 -1
  22. package/lib/tsconfig.tsbuildinfo +1 -1
  23. package/package.json +2 -2
  24. package/src/engine-components/AnimatorController.ts +1 -1
  25. package/src/engine-components/Light.ts +2 -1
  26. package/src/engine-components/ParticleSystem.ts +24 -6
  27. package/src/engine-components/Renderer.ts +1 -2
  28. package/src/engine-components/WebXR.ts +8 -0
  29. package/src/engine-components/ui/BaseUIComponent.ts +1 -1
  30. package/src/engine-components/ui/Canvas.ts +5 -0
  31. package/src/engine-components/ui/Text.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/engine",
3
- "version": "2.60.3-pre",
3
+ "version": "2.61.0-pre",
4
4
  "description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development, and can be deployed anywhere. It is flexible, extensible, and collaboration and XR come naturally.",
5
5
  "main": "dist/needle-engine.umd.cjs",
6
6
  "module": "dist/needle-engine.js",
@@ -56,7 +56,7 @@
56
56
  "devDependencies": {
57
57
  "@babel/runtime": "^7.16.0",
58
58
  "@luncheon/esbuild-plugin-gzip": "^0.1.0",
59
- "@needle-tools/gltf-transform-extensions": "^0.11.0-pre",
59
+ "@needle-tools/gltf-transform-extensions": "^0.11.2-pre",
60
60
  "@needle-tools/needle-component-compiler": "1.9.3",
61
61
  "@needle-tools/helper": "^0.2.1-pre",
62
62
  "@types/three": "0.146.0",
@@ -652,7 +652,7 @@ class RootMotionAction {
652
652
  // lastRotation.invert().premultiply(firstKeyframe).invert();
653
653
  RootMotionAction.spaceRotation[this.clip.uuid].copy(lastRotation);
654
654
 
655
- // if (debugRootMotion)
655
+ if (debugRootMotion)
656
656
  {
657
657
  const euler = new THREE.Euler().setFromQuaternion(lastRotation);
658
658
  console.log("START", this.clip.name, Mathf.toDegrees(euler.y));
@@ -131,7 +131,7 @@ export class Light extends Behaviour implements ILight {
131
131
  }
132
132
  }
133
133
  get shadowNormalBias(): number { return this._shadowNormalBias; }
134
- private _shadowNormalBias: number = 1;
134
+ private _shadowNormalBias: number = 0;
135
135
 
136
136
  /** when enabled this will remove the multiplication when setting the shadow bias settings initially */
137
137
  private _overrideShadowBiasSettings: boolean = false;
@@ -242,6 +242,7 @@ export class Light extends Behaviour implements ILight {
242
242
 
243
243
  awake() {
244
244
  this.color = new THREE.Color(this.color ?? 0xffffff);
245
+ if(debug) console.log(this.name, this);
245
246
  }
246
247
 
247
248
  onEnable(): void {
@@ -10,15 +10,17 @@ import { serializable } from "../engine/engine_serialization";
10
10
  import { RGBAColor } from "./js-extensions/RGBAColor";
11
11
  import { AxesHelper, BufferGeometry, Color, Material, Matrix4, Mesh, MeshStandardMaterial, Object3D, OneMinusDstAlphaFactor, PlaneGeometry, Quaternion, Sprite, SpriteMaterial, Vector3, Vector4 } from "three";
12
12
  import { getWorldPosition, getWorldQuaternion, getWorldScale } from "../engine/engine_three_utils";
13
- import { assign, deserializeObject } from "../engine/engine_serialization_core";
13
+ import { assign } from "../engine/engine_serialization_core";
14
14
  import { BatchedParticleRenderer, Behavior, BillBoardSettings, BurstParameters, ColorGenerator, ConstantColor, ConstantValue, EmissionState, EmitSubParticleSystem, EmitterShape, FunctionColorGenerator, FunctionJSON, FunctionValueGenerator, IntervalValue, MeshSettings, Particle, ParticleEmitter, ParticleSystem as _ParticleSystem, ParticleSystemParameters, PointEmitter, RecordState, RenderMode, RotationGenerator, SizeOverLife, TrailBatch, TrailParticle, TrailSettings, ValueGenerator } from "three.quarks";
15
15
  import { createFlatTexture } from "../engine/engine_shaders";
16
16
  import { Mathf } from "../engine/engine_math";
17
17
  import { Context } from "../engine/engine_setup";
18
18
  import { ParticleSubEmitter } from "./ParticleSystemSubEmitter";
19
- import { copyFile } from "fs";
19
+ import { NEEDLE_progressive } from "../engine/extensions/NEEDLE_progressive";
20
20
 
21
21
  const debug = getParam("debugparticles");
22
+ const suppressProgressiveLoading = getParam("noprogressive");
23
+ const debugProgressiveLoading = getParam("debugprogressive");
22
24
 
23
25
  export enum SubEmitterType {
24
26
  Birth = 0,
@@ -46,8 +48,6 @@ export class SubEmitterSystem {
46
48
  }
47
49
  }
48
50
 
49
-
50
-
51
51
  export class ParticleSystemRenderer extends Behaviour {
52
52
 
53
53
  @serializable()
@@ -69,8 +69,19 @@ export class ParticleSystemRenderer extends Behaviour {
69
69
  }
70
70
 
71
71
  getMaterial(trailEnabled: boolean = false) {
72
- if (trailEnabled === true && this.trailMaterial) return this.trailMaterial;
73
- return this.particleMaterial;
72
+ const material = (trailEnabled === true && this.trailMaterial) ? this.trailMaterial : this.particleMaterial;
73
+
74
+ // progressive load on start
75
+ // TODO: figure out how to do this before particle system rendering so we only load textures for visible materials
76
+ if (material && !suppressProgressiveLoading && material["_didRequestTextureLOD"] === undefined) {
77
+ material["_didRequestTextureLOD"] = 0;
78
+ if (debugProgressiveLoading) {
79
+ console.log("Load material LOD", material.name);
80
+ }
81
+ NEEDLE_progressive.assignTextureLOD(this.context, this.sourceId, material);
82
+ }
83
+
84
+ return material;
74
85
  }
75
86
 
76
87
  getMesh(renderMode?: ParticleSystemRenderMode) {
@@ -830,7 +841,14 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
830
841
  if (this._time > this.duration) this._time = 0;
831
842
  }
832
843
 
844
+ private lastMaterialVersion: number = -1;
833
845
  private onUpdate() {
846
+ const mat = this.renderer.getMaterial(this.trails.enabled);
847
+ if (mat && mat.version != this.lastMaterialVersion && this._particleSystem) {
848
+ this.lastMaterialVersion = mat.version;
849
+ this._particleSystem.texture = this._interface.texture;
850
+ }
851
+
834
852
  if (this._bursts) {
835
853
  this.emission.bursts = this._bursts;
836
854
  delete this._bursts;
@@ -285,7 +285,7 @@ export class Renderer extends Behaviour implements IRenderer {
285
285
  return lm !== null && lm !== undefined;
286
286
  }
287
287
 
288
- allowProgressiveLoading: boolean = true;
288
+ public allowProgressiveLoading: boolean = true;
289
289
 
290
290
  registering() {
291
291
  if (!this.enabled) {
@@ -546,7 +546,6 @@ export class Renderer extends Behaviour implements IRenderer {
546
546
  console.log("Load material LOD", material.name);
547
547
  }
548
548
  NEEDLE_progressive.assignTextureLOD(this.context, this.sourceId, material);
549
-
550
549
  }
551
550
 
552
551
  if (material.envMapIntensity !== undefined) {
@@ -16,6 +16,7 @@ import { ControllerType, WebXRController } from "./WebXRController";
16
16
  import { XRRig } from "./WebXRRig";
17
17
  import { WebXRSync } from "./WebXRSync";
18
18
  import { XRFlag, XRState, XRStateFlag } from "./XRFlag";
19
+ import { showBalloonWarning } from '../engine/debug';
19
20
 
20
21
 
21
22
  export async function detectARSupport() {
@@ -201,6 +202,13 @@ export class WebXR extends Behaviour {
201
202
  this.webAR = new WebAR(this);
202
203
  }
203
204
 
205
+ start() {
206
+ if (location.protocol == 'http:' && location.host.indexOf('localhost') < 0) {
207
+ showBalloonWarning("WebXR only works on https");
208
+ console.warn("WebXR only works on https. https://engine.needle.tools/docs/xr.html");
209
+ }
210
+ }
211
+
204
212
  onEnable() {
205
213
  if (this.isInit) return;
206
214
  if (!this.enableAR && !this.enableVR) return;
@@ -66,7 +66,7 @@ export class BaseUIComponent extends Behaviour {
66
66
  const searchFrom = this.isRoot() ? this.gameObject : this.gameObject.parent;
67
67
  this._parentComponent = GameObject.getComponentInParent(searchFrom!, BaseUIComponent);
68
68
  if (!this._parentComponent) {
69
- console.warn(`Component \"${this.name}\" doesn't have a UI parent anywhere. Do you have a UI element outside a Canvas?`, this);
69
+ console.warn(`Component \"${this.name}\" doesn't have a UI parent anywhere. Do you have an UI element outside a Canvas? UI components must be a child of a Canvas component`, this);
70
70
  return;
71
71
  }
72
72
 
@@ -7,6 +7,7 @@ import * as THREE from "three";
7
7
  import { getComponentsInChildren } from "../../engine/engine_components";
8
8
  import { IComponent } from "../../engine/engine_types";
9
9
  import { GameObject } from "../Component";
10
+ import { showBalloonMessage, showBalloonWarning } from "../../engine/debug";
10
11
 
11
12
  export enum RenderMode {
12
13
  ScreenSpaceOverlay = 0,
@@ -116,6 +117,9 @@ export class Canvas extends UIRootComponent {
116
117
  }
117
118
  }
118
119
 
120
+ applyRenderSettings(){
121
+ this.onRenderSettingsChanged();
122
+ }
119
123
 
120
124
  private _updateRenderSettingsRoutine?: Generator;
121
125
  private onRenderSettingsChanged() {
@@ -147,6 +151,7 @@ export class Canvas extends UIRootComponent {
147
151
  switch (this.renderMode) {
148
152
  case RenderMode.ScreenSpaceOverlay:
149
153
  case RenderMode.ScreenSpaceCamera:
154
+ showBalloonWarning("Screenspace Canvas is not supported yet. Please use worldspace");
150
155
  const camera = this.context.mainCameraComponent;
151
156
  if (!camera) return;
152
157
  const canvas = this.gameObject;
@@ -91,7 +91,7 @@ export class Text extends Graphic {
91
91
  return;
92
92
  }
93
93
  //@ts-ignore
94
- this._textMeshUi[0].set({ content: val });
94
+ this._textMeshUi[0].set({ fontSize: val });
95
95
  this.markDirty();
96
96
  }
97
97
  }