@needle-tools/engine 4.7.4 → 4.8.0-next.71dbdab

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 (38) hide show
  1. package/dist/gltf-progressive--2HtE1d8.umd.cjs +8 -0
  2. package/dist/gltf-progressive-CeuEsYpY.min.js +8 -0
  3. package/dist/gltf-progressive-DY5t1MFv.js +1370 -0
  4. package/dist/loader.worker-8olmVOL4.js +1 -0
  5. package/dist/needle-engine.bundle-B39uCVgy.js +42600 -0
  6. package/dist/needle-engine.bundle-CvGXlxjL.umd.cjs +1607 -0
  7. package/dist/needle-engine.bundle-D598TFE7.min.js +1607 -0
  8. package/dist/needle-engine.d.ts +15 -15
  9. package/dist/needle-engine.js +591 -592
  10. package/dist/needle-engine.min.js +1 -1
  11. package/dist/needle-engine.umd.cjs +1 -1
  12. package/dist/{postprocessing-BzY0H7ry.min.js → postprocessing-ChsrvDkI.min.js} +54 -54
  13. package/dist/{postprocessing-vKBVFpSz.js → postprocessing-DElbMQgB.js} +479 -483
  14. package/dist/{postprocessing-Dw2OCMp4.umd.cjs → postprocessing-DtxaELce.umd.cjs} +66 -66
  15. package/dist/{three-examples-DUcCNw9s.umd.cjs → three-examples-BhQvv1B9.umd.cjs} +11 -11
  16. package/dist/{three-examples-tvuhV8Ne.js → three-examples-CM6Iip03.js} +23 -27
  17. package/dist/{three-examples-BMOhDaYR.min.js → three-examples-D2zemuAM.min.js} +12 -12
  18. package/dist/{three-mesh-ui-CxuWt7m-.js → three-mesh-ui-D6Mz5Yl7.js} +799 -810
  19. package/dist/three-mesh-ui-DWcMuyQ_.min.js +406 -0
  20. package/dist/three-mesh-ui-tt0buEDC.umd.cjs +406 -0
  21. package/dist/{vendor-BmYIgaS1.js → vendor-ClB-U1Hn.js} +10 -10
  22. package/dist/{vendor-Cavtu3CP.umd.cjs → vendor-bOWOWClg.umd.cjs} +1 -1
  23. package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.d.ts +1 -1
  24. package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +1 -0
  25. package/lib/engine-components/postprocessing/PostProcessingHandler.js +8 -0
  26. package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
  27. package/package.json +5 -5
  28. package/plugins/vite/dependencies.js +28 -19
  29. package/plugins/vite/dependency-watcher.js +6 -1
  30. package/src/engine-components/postprocessing/PostProcessingHandler.ts +14 -0
  31. package/dist/gltf-progressive-Bgh1c4Fd.js +0 -1224
  32. package/dist/gltf-progressive-D6f5talj.min.js +0 -8
  33. package/dist/gltf-progressive-otA_hxSA.umd.cjs +0 -8
  34. package/dist/needle-engine.bundle-Bb6xVcZE.min.js +0 -1607
  35. package/dist/needle-engine.bundle-BldBPoPh.js +0 -43846
  36. package/dist/needle-engine.bundle-ByrSH-zp.umd.cjs +0 -1607
  37. package/dist/three-mesh-ui-B3p3gyUz.min.js +0 -406
  38. package/dist/three-mesh-ui-CQiIQIlA.umd.cjs +0 -406
@@ -27,32 +27,41 @@ export const needleDependencies = (command, config, userSettings) => {
27
27
  }
28
28
  }
29
29
 
30
+ const excludeDependencies = [
31
+ "three-mesh-bvh",
32
+ "@needle-tools/gltf-progressive"
33
+ ]
34
+
30
35
  /**
31
36
  * @param {import('vite').UserConfig} config
32
37
  */
33
38
  function handleOptimizeDeps(config) {
34
- if (config.optimizeDeps?.include?.includes("three-mesh-bvh")) {
35
- console.log("[needle-dependencies] three-mesh-bvh is included in the optimizeDeps.include array. This may cause issues with the worker import.");
36
- }
37
- else {
38
- if (!config.optimizeDeps) {
39
- config.optimizeDeps = {};
39
+ excludeDependencies.forEach(dep => {
40
+ if (config.optimizeDeps?.include?.includes(dep)) {
41
+ console.log(`[needle-dependencies] ${dep} is included in the optimizeDeps.include array. This may cause issues with the worker import.`);
40
42
  }
41
- if (!config.optimizeDeps.exclude) {
42
- config.optimizeDeps.exclude = [];
43
- }
44
- console.log("[needle-dependencies] Adding three-mesh-bvh to the optimizeDeps.exclude array.");
45
- // This needs to be excluded from optimization because otherwise the worker import fails
46
- // three-mesh-bvh/src/workers/generateMeshBVH.worker.js?worker
47
- config.optimizeDeps.exclude.push("three-mesh-bvh");
43
+ else {
44
+ if (!config.optimizeDeps) {
45
+ config.optimizeDeps = {};
46
+ }
47
+ if (!config.optimizeDeps.exclude) {
48
+ config.optimizeDeps.exclude = [];
49
+ }
48
50
 
49
- if (!config.server) config.server = {};
50
- if (!config.server.fs) config.server.fs = {};
51
- if (config.server.fs.strict === undefined) {
52
- // we need to disable strictness to allow importing the worker from three-mesh-bvh node_modules in our GenerateMeshBVHWorker.js file
53
- config.server.fs.strict = false;
51
+ // This needs to be excluded from optimization because otherwise the worker import fails
52
+ // three-mesh-bvh/src/workers/generateMeshBVH.worker.js?worker
53
+ // same for gltf-progressive
54
+ console.log(`[needle-dependencies] Adding ${dep} to the optimizeDeps.exclude array to support workers.`);
55
+ config.optimizeDeps.exclude.push(dep);
56
+
57
+ if (!config.server) config.server = {};
58
+ if (!config.server.fs) config.server.fs = {};
59
+ if (config.server.fs.strict === undefined) {
60
+ // we need to disable strictness to allow importing the worker from three-mesh-bvh node_modules in our GenerateMeshBVHWorker.js file
61
+ config.server.fs.strict = false;
62
+ }
54
63
  }
55
- }
64
+ });
56
65
  }
57
66
 
58
67
  /**
@@ -169,12 +169,17 @@ function testIfInstallIsRequired(projectDir, packageJson) {
169
169
  expectedVersion === "alpha" ||
170
170
  expectedVersion === "canary" ||
171
171
  expectedVersion === "experimental";
172
+ // We can not automatically install dependencies with "4" or "4.6" as a version
173
+ // const isFullSemver = expectedVersion.match(/^\d+\.\d+\.\d+(-\w+)?(\.\d+)?$/);
172
174
  if (!isRange && !isTagName) {
173
175
  const packageJsonPath = path.join(depPath, "package.json");
174
176
  /** @type {String} */
175
177
  const installedVersion = JSON.parse(readFileSync(packageJsonPath, "utf8")).version;
178
+ let versionToCompare = expectedVersion.split("@").pop();
179
+ while (versionToCompare?.startsWith("^")) versionToCompare = versionToCompare.substring(1);
176
180
  // fix check for cases where the version contains a alias e.g. npm:three@0.160.3
177
- if (expectedVersion.trimEnd().endsWith(installedVersion.trim()) == false) {
181
+ const actualVersion = installedVersion.split("@").pop();
182
+ if (actualVersion && versionToCompare && versionToCompare.trimEnd().startsWith(actualVersion.trim()) == false) {
178
183
  log(`Dependency ${key} is installed but version is not the right one. Expected \"${expectedVersion}/" but got \"${installedVersion}\"`)
179
184
  return true;
180
185
  }
@@ -100,6 +100,8 @@ export class PostProcessingHandler {
100
100
  if (context.composer === this._composer) {
101
101
  context.composer = null;
102
102
  }
103
+
104
+ this.handleDevicePixelRatio();
103
105
  }
104
106
 
105
107
  dispose() {
@@ -476,6 +478,11 @@ export class PostProcessingHandler {
476
478
 
477
479
  }
478
480
 
481
+
482
+ this.handleDevicePixelRatio();
483
+
484
+
485
+
479
486
  // DEBUG LAND BELOW
480
487
  if (debug) console.log("[PostProcessing] Passes →", [...composer.passes], "\n---------------------------------\n• " + composer.passes.map(i => i.name || (i.constructor.name + "*")).join("\n• ") + "\n");
481
488
  if (debug) this._onCreateEffectsDebug(this._composer!, cam);
@@ -497,6 +504,13 @@ export class PostProcessingHandler {
497
504
  }
498
505
 
499
506
 
507
+ private handleDevicePixelRatio() {
508
+ // Keep user device pixel ratio (if any) https://linear.app/needle/issue/NE-6661
509
+ if (typeof this.context.devicePixelRatio === "number") {
510
+ this.context.requestSizeUpdate();
511
+ }
512
+ }
513
+
500
514
 
501
515
  private _menuEntry: HTMLSelectElement | null = null;
502
516
  private _passIndices: number[] | null = null;