@needle-tools/engine 2.67.12-pre → 2.67.13-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/engine",
3
- "version": "2.67.12-pre",
3
+ "version": "2.67.13-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": "lib/needle-engine.js",
@@ -59,8 +59,8 @@
59
59
  "flatbuffers": "2.0.4",
60
60
  "md5": "^2.3.0",
61
61
  "peerjs": "1.3.2",
62
- "simplex-noise": "^4.0.1",
63
62
  "postprocessing": "^6.30.1",
63
+ "simplex-noise": "^4.0.1",
64
64
  "stats.js": "^0.17.0",
65
65
  "three": "npm:@needle-tools/three@^0.146.7",
66
66
  "three-mesh-ui": "^6.4.5",
@@ -75,10 +75,9 @@
75
75
  "@needle-tools/helper": "^0.4.5",
76
76
  "@needle-tools/needle-component-compiler": "1.9.3",
77
77
  "@types/three": "0.146.0",
78
- "copy-files-from-to": "^3.7.0",
79
78
  "esbuild": "^0.15.10",
80
79
  "esbuild-node-externals": "^1.5.0",
81
- "fs-extra": "^11.1.0",
80
+ "fs-extra": "^11.1.1",
82
81
  "jsdoc-babel": "^0.5.0",
83
82
  "jsdoc-to-markdown": "^7.1.1",
84
83
  "madge": "^5.0.1",
@@ -1,7 +1,6 @@
1
1
 
2
- import { copy } from 'fs-extra'
3
- import { resolve } from 'path'
4
- import { existsSync } from 'fs';
2
+ import { resolve, join } from 'path'
3
+ import { existsSync, statSync, mkdirSync, readdirSync, copyFileSync, mkdir } from 'fs';
5
4
 
6
5
 
7
6
  /** copy files on build from assets to dist */
@@ -11,32 +10,60 @@ export const needleCopyFiles = (command, config, userSettings) => {
11
10
  return;
12
11
  }
13
12
 
13
+ const copyIncludesFromEngine = config?.copyIncludesFromEngine ?? true;
14
+
14
15
  return {
15
16
  name: 'needle-copy-files',
16
17
  apply: 'build',
17
18
  async closeBundle() {
18
19
  const baseDir = process.cwd();
20
+ const pluginName = "needle-copy-files";
19
21
 
20
22
  const outdirName = "dist";
21
23
  const outDir = resolve(baseDir, outdirName);
22
24
  if (!existsSync(outDir)) {
23
- console.log(`No ${outdirName} folder found, skipping copy files: ${outDir}`);
24
- return;
25
+ mkdirSync(outDir);
26
+ }
27
+
28
+ if (copyIncludesFromEngine !== false) {
29
+ // copy include from engine
30
+ const engineIncludeDir = resolve(baseDir, 'node_modules', '@needle-tools', 'engine', 'src', 'include');
31
+ if (existsSync(engineIncludeDir)) {
32
+ console.log(`[${pluginName}] - Copy engine include to ${baseDir}/include`)
33
+ const targetDir = resolve(baseDir, 'include');
34
+ copyRecursiveSync(engineIncludeDir, targetDir);
35
+ }
25
36
  }
37
+
26
38
  // copy assets dir
27
39
  const assetsDir = resolve(baseDir, 'assets');
28
40
  if (existsSync(assetsDir)) {
29
- console.log(`Copy assets to ${outdirName}/assets`)
41
+ console.log(`[${pluginName}] - Copy assets to ${outdirName}/assets`)
30
42
  const targetDir = resolve(outDir, 'assets');
31
- await copy(assetsDir, targetDir, { overwrite: true });
43
+ copyRecursiveSync(assetsDir, targetDir);
32
44
  }
33
45
  // copy include dir
34
46
  const includeDir = resolve(baseDir, 'include');
35
47
  if (existsSync(includeDir)) {
36
- console.log(`Copy include to ${outdirName}/include`)
48
+ console.log(`[${pluginName}] - Copy include to ${outdirName}/include`)
37
49
  const targetDir = resolve(outDir, 'include');
38
- await copy(includeDir, targetDir, { overwrite: true });
50
+ copyRecursiveSync(includeDir, targetDir);
39
51
  }
40
52
  }
41
53
  }
42
- }
54
+ }
55
+
56
+ function copyRecursiveSync(src, dest) {
57
+ var exists = existsSync(src);
58
+ var stats = exists && statSync(src);
59
+ var isDirectory = exists && stats.isDirectory();
60
+ if (isDirectory) {
61
+ if (!existsSync(dest))
62
+ mkdirSync(dest);
63
+ readdirSync(src).forEach(function (childItemName) {
64
+ copyRecursiveSync(join(src, childItemName), join(dest, childItemName));
65
+ });
66
+ } else {
67
+ copyFileSync(src, dest);
68
+ }
69
+ };
@@ -43,7 +43,8 @@ export const needleReload = (command, config, userSettings) => {
43
43
  else if (!config.server.watch.ignored) config.server.watch.ignored = [];
44
44
  for (const pattern of ignorePatterns)
45
45
  config.server.watch.ignored.push(pattern);
46
- setTimeout(() => console.log("Updated server ignore patterns: ", config.server.watch.ignored), 100);
46
+ if(config?.debug === true || userSettings?.debug === true)
47
+ setTimeout(() => console.log("Updated server ignore patterns: ", config.server.watch.ignored), 100);
47
48
  },
48
49
  handleHotUpdate(args) {
49
50
  args.buildDirectory = buildDirectory;
@@ -145,7 +145,7 @@ export class Animation extends Behaviour {
145
145
  return false;
146
146
  }
147
147
 
148
- play(clipOrNumber: AnimationClip | number | string | undefined, options?: PlayOptions): Promise<AnimationAction> | void {
148
+ play(clipOrNumber: AnimationClip | number | string | undefined = 0, options?: PlayOptions): Promise<AnimationAction> | void {
149
149
  if (debug) console.log("PLAY", clipOrNumber)
150
150
  this.init();
151
151
  if (!this.mixer) {
@@ -171,8 +171,8 @@ export class Animation extends Behaviour {
171
171
  if (!options) options = {};
172
172
  if (!options.minMaxOffsetNormalized) options.minMaxOffsetNormalized = this.minMaxOffsetNormalized;
173
173
  if (!options.minMaxSpeed) options.minMaxSpeed = this.minMaxSpeed;
174
- if (!options.loop) options.loop = this.loop;
175
- if (!options.clampWhenFinished) options.clampWhenFinished = this.clampWhenFinished;
174
+ if (options.loop === undefined) options.loop = this.loop;
175
+ if (options.clampWhenFinished === undefined) options.clampWhenFinished = this.clampWhenFinished;
176
176
  for (const act of this.actions) {
177
177
  if (act.getClip() === clip) {
178
178
  return this.internalOnPlay(act, options);
@@ -639,7 +639,7 @@ export class Renderer extends Behaviour implements IRenderer {
639
639
  }
640
640
  }
641
641
 
642
- private applySettings(go: THREE.Object3D) {
642
+ applySettings(go: THREE.Object3D) {
643
643
  go.receiveShadow = this.receiveShadows;
644
644
  if (this.shadowCastingMode == ShadowCastingMode.On) {
645
645
  go.castShadow = true;
@@ -734,15 +734,16 @@ class InstancingHandler {
734
734
  public setup(renderer: Renderer, obj: THREE.Object3D, context: Context, handlesArray: InstanceHandle[] | null, args: InstancingSetupArgs, level: number = 0)
735
735
  : InstanceHandle[] | null {
736
736
 
737
+ // make sure setting casting settings are applied so when we add the mesh to the InstancedMesh we can ask for the correct cast shadow setting
738
+ renderer.applySettings(obj);
737
739
  const res = this.tryCreateOrAddInstance(obj, context, args);
738
740
  if (res) {
739
741
  renderer.loadProgressiveTextures(res.instancer.material);
740
742
  if (handlesArray === null) handlesArray = [];
741
743
  handlesArray.push(res);
742
- return handlesArray;
743
744
  }
744
745
 
745
- if (level <= 0 && obj.type !== "Mesh") {
746
+ else if (level <= 0 && obj.type !== "Mesh") {
746
747
  const nextLevel = level + 1;
747
748
  for (const ch of obj.children) {
748
749
  handlesArray = this.setup(renderer, ch, context, handlesArray, args, nextLevel);
@@ -799,10 +800,8 @@ class InstancingHandler {
799
800
  let previousMatrix: THREE.Matrix4 = obj.matrixWorld.clone();
800
801
  const matrixChangeWrapper = (a: Matrix4, b: Matrix4) => {
801
802
  const newMatrixWorld = original(a, b);
802
- // console.warn("MULT", obj.matrixWorldNeedsUpdate);
803
803
  if (obj[NEED_UPDATE_INSTANCE_KEY] || previousMatrix.equals(newMatrixWorld) === false) {
804
804
  previousMatrix.copy(newMatrixWorld)
805
- // handle.setMatrix(newMatrixWorld);
806
805
  obj[NEED_UPDATE_INSTANCE_KEY] = true;
807
806
  }
808
807
  return newMatrixWorld;
@@ -865,6 +864,13 @@ class InstanceHandle {
865
864
 
866
865
  class InstancedMeshRenderer {
867
866
 
867
+ set castShadow(val: boolean) {
868
+ this.inst.castShadow = val;
869
+ }
870
+ set receiveShadow(val: boolean) {
871
+ this.inst.receiveShadow = val;
872
+ }
873
+
868
874
  public name: string = "";
869
875
  public geo: THREE.BufferGeometry;
870
876
  public material: THREE.Material;
@@ -915,6 +921,14 @@ class InstancedMeshRenderer {
915
921
  return null;
916
922
  }
917
923
  const handle = new InstanceHandle(-1, obj, this);
924
+
925
+ if (obj.castShadow === true && this.inst.castShadow === false) {
926
+ this.inst.castShadow = true;
927
+ }
928
+ if (obj.receiveShadow === true && this.inst.receiveShadow === false) {
929
+ this.inst.receiveShadow = true;
930
+ }
931
+
918
932
  this.add(handle);
919
933
  return handle;
920
934
  }
@@ -0,0 +1 @@
1
+ export * from "./ui/PointerEvents"
@@ -11,6 +11,7 @@ export { GameObject, Behaviour } from "./engine-components/Component";
11
11
  export { serializable, serializeable } from "./engine/engine_serialization_decorator";
12
12
  export { Collision } from "./engine/engine_types";
13
13
  export * from "./engine/api";
14
+ export * from "./engine-components/api";
14
15
  export * from "./engine-components/codegen/components";
15
16
  export * from "./engine-components/js-extensions/Object3D";
16
17