@needle-tools/engine 4.16.1-next.e45724f → 4.16.2

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 (85) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/components.needle.json +1 -1
  3. package/dist/{needle-engine.bundle-CupCi9ih.min.js → needle-engine.bundle-BOzZVXHu.min.js} +125 -125
  4. package/dist/{needle-engine.bundle-Kai1_GLU.js → needle-engine.bundle-VXttgVve.js} +3854 -3848
  5. package/dist/{needle-engine.bundle-CWDn3Osx.umd.cjs → needle-engine.bundle-nJtehyVz.umd.cjs} +125 -125
  6. package/dist/needle-engine.d.ts +24 -8
  7. package/dist/needle-engine.js +2 -2
  8. package/dist/needle-engine.min.js +1 -1
  9. package/dist/needle-engine.umd.cjs +1 -1
  10. package/lib/engine-components/EventType.d.ts +1 -13
  11. package/lib/engine-components/EventType.js +13 -12
  12. package/lib/engine-components/EventType.js.map +1 -1
  13. package/lib/engine-components/ReflectionProbe.d.ts +24 -8
  14. package/lib/engine-components/ReflectionProbe.js +33 -15
  15. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  16. package/package.json +10 -2
  17. package/plugins/next/next.d.ts +7 -0
  18. package/plugins/next/next.js +2 -2
  19. package/plugins/types/userconfig.d.ts +4 -6
  20. package/plugins/vite/ai.d.ts +16 -0
  21. package/plugins/vite/ai.js +2 -2
  22. package/plugins/vite/alias.d.ts +6 -0
  23. package/plugins/vite/alias.js +2 -2
  24. package/plugins/vite/asap.d.ts +6 -0
  25. package/plugins/vite/asap.js +1 -1
  26. package/plugins/vite/build-pipeline.d.ts +6 -0
  27. package/plugins/vite/build-pipeline.js +1 -1
  28. package/plugins/vite/build.d.ts +6 -0
  29. package/plugins/vite/build.js +1 -1
  30. package/plugins/vite/buildinfo.d.ts +6 -0
  31. package/plugins/vite/buildinfo.js +1 -1
  32. package/plugins/vite/copyfiles.d.ts +6 -0
  33. package/plugins/vite/copyfiles.js +1 -1
  34. package/plugins/vite/custom-element-data.d.ts +11 -0
  35. package/plugins/vite/custom-element-data.js +1 -1
  36. package/plugins/vite/defines.d.ts +9 -0
  37. package/plugins/vite/defines.js +1 -1
  38. package/plugins/vite/dependencies.d.ts +7 -1
  39. package/plugins/vite/dependencies.js +1 -1
  40. package/plugins/vite/dependency-watcher.d.ts +6 -0
  41. package/plugins/vite/dependency-watcher.js +1 -1
  42. package/plugins/vite/drop-client.d.ts +1 -0
  43. package/plugins/vite/drop.d.ts +6 -0
  44. package/plugins/vite/drop.js +1 -1
  45. package/plugins/vite/editor-connection.d.ts +7 -0
  46. package/plugins/vite/editor-connection.js +1 -1
  47. package/plugins/vite/facebook-instant-games.d.ts +6 -0
  48. package/plugins/vite/facebook-instant-games.js +1 -1
  49. package/plugins/vite/imports-logger.d.ts +7 -0
  50. package/plugins/vite/imports-logger.js +1 -1
  51. package/plugins/vite/index.d.ts +27 -27
  52. package/plugins/vite/index.js +1 -1
  53. package/plugins/vite/license.d.ts +6 -0
  54. package/plugins/vite/license.js +2 -2
  55. package/plugins/vite/local-files-core.d.ts +7 -1
  56. package/plugins/vite/local-files-core.js +2 -2
  57. package/plugins/vite/local-files-internals.d.ts +3 -0
  58. package/plugins/vite/logger.d.ts +7 -0
  59. package/plugins/vite/logger.js +1 -1
  60. package/plugins/vite/meta.d.ts +6 -0
  61. package/plugins/vite/meta.js +1 -1
  62. package/plugins/vite/needle-app.d.ts +6 -0
  63. package/plugins/vite/needle-app.js +1 -1
  64. package/plugins/vite/npm.d.ts +3 -0
  65. package/plugins/vite/npm.js +1 -1
  66. package/plugins/vite/peer.d.ts +6 -0
  67. package/plugins/vite/peer.js +1 -1
  68. package/plugins/vite/poster-client.d.ts +1 -0
  69. package/plugins/vite/poster.d.ts +6 -0
  70. package/plugins/vite/poster.js +2 -2
  71. package/plugins/vite/pwa.d.ts +6 -0
  72. package/plugins/vite/pwa.js +1 -1
  73. package/plugins/vite/reload-client.d.ts +1 -0
  74. package/plugins/vite/reload.d.ts +6 -0
  75. package/plugins/vite/reload.js +1 -1
  76. package/plugins/vite/server.d.ts +6 -0
  77. package/plugins/vite/server.js +2 -2
  78. package/plugins/vite/transform-codegen.d.ts +7 -0
  79. package/plugins/vite/transform-codegen.js +1 -1
  80. package/plugins/vite/transform.d.ts +4 -0
  81. package/plugins/vite/transform.js +1 -1
  82. package/plugins/vite/vite-4.4-hack.d.ts +4 -0
  83. package/plugins/vite/vite-4.4-hack.js +1 -1
  84. package/src/engine-components/EventType.ts +13 -12
  85. package/src/engine-components/ReflectionProbe.ts +37 -19
@@ -1,29 +1,3 @@
1
- export { needleAI } from "./ai.js";
2
- export { needleAsap } from "./asap.js";
3
- export { needleDefines } from "./defines.js";
4
- export { needleBuildPipeline } from "./build-pipeline.js";
5
- export { needleBuild } from "./build.js";
6
- export { needleMeta } from "./meta.js";
7
- export { needlePoster } from "./poster.js";
8
- export { needlePWA } from "./pwa.js";
9
- export { needleReload } from "./reload.js";
10
- export { needleDrop } from "./drop.js";
11
- export { editorConnection } from "./editor-connection.js";
12
- export { needleCopyFiles } from "./copyfiles.js";
13
- export { needleViteAlias } from "./alias.js";
14
- export { needleCustomElementData } from "./custom-element-data.js";
15
- export { needleTransformCodegen } from "./transform-codegen.js";
16
- export { needleLicense } from "./license.js";
17
- export { needlePeerjs } from "./peer.js";
18
- export { needleDependencyWatcher } from "./dependency-watcher.js";
19
- export { needleDependencies } from "./dependencies.js";
20
- export { needleFacebookInstantGames } from "./facebook-instant-games.js";
21
- export { needleImportsLogger } from "./imports-logger.js";
22
- export { needleBuildInfo } from "./buildinfo.js";
23
- export { needleApp } from "./needle-app.js";
24
- export { needleServer } from "./server.js";
25
- export * from "./gzip.js";
26
- export * from "./config.js";
27
1
  /** # Needle Engine plugins for Vite
28
2
  * Plugins include hot reload support, meta tags, defines, build pipeline, PWA, and more.
29
3
  * ## Using PWA
@@ -50,5 +24,31 @@ export * from "./config.js";
50
24
  * @param {import('../types/index.js').userSettings} [userSettings]
51
25
  * @returns {Promise<import('vite').Plugin[]>}
52
26
  */
53
- export const needlePlugins: any;
27
+ export function needlePlugins(command: "build" | "serve", config?: import("../types/needleConfig").needleMeta | null | undefined, userSettings?: import("../types/index.js").userSettings): Promise<import("vite").Plugin[]>;
28
+ export { needleAI } from "./ai.js";
29
+ export { needleAsap } from "./asap.js";
30
+ export { needleDefines } from "./defines.js";
31
+ export { needleBuildPipeline } from "./build-pipeline.js";
32
+ export { needleBuild } from "./build.js";
33
+ export { needleMeta } from "./meta.js";
34
+ export { needlePoster } from "./poster.js";
35
+ export { needlePWA } from "./pwa.js";
36
+ export { needleReload } from "./reload.js";
37
+ export { needleDrop } from "./drop.js";
38
+ export { editorConnection } from "./editor-connection.js";
39
+ export { needleCopyFiles } from "./copyfiles.js";
40
+ export { needleViteAlias } from "./alias.js";
41
+ export { needleCustomElementData } from "./custom-element-data.js";
42
+ export { needleTransformCodegen } from "./transform-codegen.js";
43
+ export { needleLicense } from "./license.js";
44
+ export { needlePeerjs } from "./peer.js";
45
+ export { needleDependencyWatcher } from "./dependency-watcher.js";
46
+ export { needleDependencies } from "./dependencies.js";
47
+ export { needleFacebookInstantGames } from "./facebook-instant-games.js";
48
+ export { needleImportsLogger } from "./imports-logger.js";
49
+ export { needleBuildInfo } from "./buildinfo.js";
50
+ export { needleApp } from "./needle-app.js";
51
+ export { needleServer } from "./server.js";
52
+ export * from "./gzip.js";
53
+ export * from "./config.js";
54
54
  export { needleMakeFilesLocal, needleLocalFilesSceneAnalysis } from "./local-files.js";
@@ -115,7 +115,7 @@ const defaultUserSettings = {
115
115
  * @param {import('../types/index.js').userSettings} [userSettings]
116
116
  * @returns {Promise<import('vite').Plugin[]>}
117
117
  */
118
- export const needlePlugins = async (command, config = undefined, userSettings = {}) => {
118
+ export async function needlePlugins(command, config = undefined, userSettings = {}) {
119
119
 
120
120
  if (!config) config = {}
121
121
 
@@ -1 +1,7 @@
1
+ /** This plugin is used to apply the license to the needle engine.
2
+ * @param {"build" | "serve"} command
3
+ * @param {import('../types/needleConfig').needleMeta | null | undefined} config
4
+ * @param {import('../types/userconfig.js').userSettings} userSettings
5
+ * @returns {import('vite').Plugin}
6
+ */
1
7
  export function needleLicense(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types/userconfig.js").userSettings): import("vite").Plugin;
@@ -7,7 +7,7 @@ import { loadConfig } from './config.js';
7
7
  * @param {import('../types/userconfig.js').userSettings} userSettings
8
8
  * @returns {import('vite').Plugin}
9
9
  */
10
- export const needleLicense = (command, config, userSettings) => {
10
+ export function needleLicense(command, config, userSettings) {
11
11
  let license = undefined;
12
12
 
13
13
  return {
@@ -53,4 +53,4 @@ export const needleLicense = (command, config, userSettings) => {
53
53
  }
54
54
  }
55
55
  }
56
- };
56
+ }
@@ -1,3 +1,10 @@
1
+ /**
2
+ * @param {"build" | "serve"} command
3
+ * @param {unknown} _config
4
+ * @param {import('../types').userSettings} userSettings
5
+ * @returns {import('vite').Plugin | null}
6
+ */
7
+ export function needleMakeFilesLocal(command: "build" | "serve", _config: unknown, userSettings: import("../types").userSettings): import("vite").Plugin | null;
1
8
  /**
2
9
  * @param {LocalizationOptions} options
3
10
  * @param {AutoPolicy | null} autoPolicy
@@ -36,7 +43,6 @@ export function getFeatureBasePath(basePath: string, feature: string): string;
36
43
  */
37
44
  export function handleWebXRProfiles(baseUrl: string, basePath: string, currentDir: string, context: LocalizationContext): Promise<string>;
38
45
  export { makeFilesLocalIsEnabled };
39
- export function needleMakeFilesLocal(command: "build" | "serve", _config: unknown, userSettings: import("../types").userSettings): import("vite").Plugin | null;
40
46
  export type LocalizationContext = import("./local-files-types.js").LocalizationContext;
41
47
  export type LocalizationOptions = import("./local-files-types.js").LocalizationOptions;
42
48
  export type LocalizationStats = import("./local-files-types.js").LocalizationStats;
@@ -213,7 +213,7 @@ function recordLocalizedAsset(stats, url, sizeBytes, mimeType) {
213
213
  * @param {import('../types').userSettings} userSettings
214
214
  * @returns {import('vite').Plugin | null}
215
215
  */
216
- export const needleMakeFilesLocal = (command, _config, userSettings) => {
216
+ export function needleMakeFilesLocal(command, _config, userSettings) {
217
217
  if (!makeFilesLocalIsEnabled(userSettings)) {
218
218
  return null;
219
219
  }
@@ -373,7 +373,7 @@ export const needleMakeFilesLocal = (command, _config, userSettings) => {
373
373
  }
374
374
  });
375
375
  return plugin;
376
- };
376
+ }
377
377
 
378
378
  /**
379
379
  * @param {LocalizationOptions} options
@@ -0,0 +1,3 @@
1
+ export { getActiveHandlers, getFeatureBasePath, handleWebXRProfiles, makeLocal, makeLocalHtml } from "./local-files-core.js";
2
+ export { analyzeProjectGlbs, buildAutoPolicy, collectAssetGlbs, collectIndexHtmlSkyboxUrls, collectNeedleComponentExtensionBlobs, detectAutoPolicy, getWebXRProfilesForMode, hasAutoFeatureSelection, readGlbJsonChunk, resolveSkyboxSelectionUrls, resolveSkyboxValueToUrl, shouldHandleUrlInAutoMode } from "./local-files-analysis.js";
3
+ export { fixDracoRangeQueryProbe, fixRelativeNewURL, getRelativeToBasePath } from "./local-files-utils.js";
@@ -1 +1,8 @@
1
+ /**
2
+ * write logs to local file
3
+ * @param {string} command
4
+ * @param {unknown} _config
5
+ * @param {import('../types/userconfig.js').userSettings} userSettings
6
+ * @returns {import('vite').Plugin | null}
7
+ */
1
8
  export function needleLogger(command: string, _config: unknown, userSettings: import("../types/userconfig.js").userSettings): import("vite").Plugin | null;
@@ -15,7 +15,7 @@ const __dirname = path.dirname(__filename);
15
15
  * @param {import('../types/userconfig.js').userSettings} userSettings
16
16
  * @returns {import('vite').Plugin | null}
17
17
  */
18
- export const needleLogger = (command, _config, userSettings) => {
18
+ export function needleLogger(command, _config, userSettings) {
19
19
 
20
20
  if (userSettings?.disableLogging === true) {
21
21
  return null;
@@ -1 +1,7 @@
1
+ /**
2
+ * @param {"build" | "serve"} command
3
+ * @param {import('../types/needleConfig').needleMeta | null} config
4
+ * @param {import('../types').userSettings} userSettings
5
+ * @returns {import('vite').Plugin}
6
+ */
1
7
  export function needleMeta(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null, userSettings: import("../types").userSettings): import("vite").Plugin;
@@ -11,7 +11,7 @@ import { needleGreenBold, needleLog } from './logging.js';
11
11
  * @param {import('../types').userSettings} userSettings
12
12
  * @returns {import('vite').Plugin}
13
13
  */
14
- export const needleMeta = (command, config, userSettings) => {
14
+ export function needleMeta(command, config, userSettings) {
15
15
 
16
16
  // we can check if this is a build
17
17
  const isBuild = command === 'build';
@@ -1 +1,7 @@
1
+ /**
2
+ * @param {'serve' | 'build'} command
3
+ * @param {{} | undefined | null} config
4
+ * @param {import('../types').userSettings} userSettings
5
+ * @returns {import('vite').Plugin[] | null}
6
+ */
1
7
  export function needleApp(command: "serve" | "build", config: {} | undefined | null, userSettings: import("../types").userSettings): import("vite").Plugin[] | null;
@@ -10,7 +10,7 @@ import { needleLog } from './logging.js';
10
10
  * @param {import('../types').userSettings} userSettings
11
11
  * @returns {import('vite').Plugin[] | null}
12
12
  */
13
- export const needleApp = (command, config, userSettings) => {
13
+ export function needleApp(command, config, userSettings) {
14
14
 
15
15
  if (command !== "build") {
16
16
  return null;
@@ -1 +1,4 @@
1
+ /**
2
+ * @param {import('../types').userSettings} userSettings
3
+ */
1
4
  export function needleNPM(command: any, config: any, userSettings: import("../types").userSettings): void;
@@ -3,6 +3,6 @@ import { ensureNpmDirectoryExists } from '../common/npm.js';
3
3
  /**
4
4
  * @param {import('../types').userSettings} userSettings
5
5
  */
6
- export const needleNPM = (command, config, userSettings) => {
6
+ export function needleNPM(command, config, userSettings) {
7
7
  ensureNpmDirectoryExists();
8
8
  }
@@ -1 +1,7 @@
1
+ /**
2
+ * @param {"build" | "serve"} command
3
+ * @param {import('../types/needleConfig').needleMeta | null | undefined} config
4
+ * @param {import('../types').userSettings} userSettings
5
+ * @returns {import("vite").Plugin | undefined}
6
+ */
1
7
  export function needlePeerjs(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin | undefined;
@@ -7,7 +7,7 @@ import { needleLog } from './logging.js';
7
7
  * @param {import('../types').userSettings} userSettings
8
8
  * @returns {import("vite").Plugin | undefined}
9
9
  */
10
- export const needlePeerjs = (command, config, userSettings) => {
10
+ export function needlePeerjs(command, config, userSettings) {
11
11
 
12
12
  if (userSettings.noPeer === true) return;
13
13
 
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,8 @@
1
1
  export function getPosterPath(): string;
2
+ /**
3
+ * @param {"build" | "serve"} command
4
+ * @param {import('../types/needleConfig').needleMeta | null | undefined} config
5
+ * @param {import('../types').userSettings} userSettings
6
+ * @returns {import('vite').Plugin | undefined}
7
+ */
2
8
  export function needlePoster(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin | undefined;
@@ -15,7 +15,7 @@ export function getPosterPath() {
15
15
  * @param {import('../types').userSettings} userSettings
16
16
  * @returns {import('vite').Plugin | undefined}
17
17
  */
18
- export const needlePoster = (command, config, userSettings) => {
18
+ export function needlePoster(command, config, userSettings) {
19
19
  // only relevant for local development
20
20
  if (command === 'build') return [];
21
21
 
@@ -79,4 +79,4 @@ export const needlePoster = (command, config, userSettings) => {
79
79
  },
80
80
  },
81
81
  }
82
- };
82
+ }
@@ -1 +1,7 @@
1
+ /** Provides reasonable defaults for a PWA manifest and workbox settings.
2
+ * @param {"build" | "serve"} command
3
+ * @param {import("../types/needleConfig").needleMeta | null} config
4
+ * @param {import('../types').userSettings} userSettings
5
+ * @returns {import('vite').Plugin | undefined}
6
+ */
1
7
  export function needlePWA(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null, userSettings: import("../types").userSettings): import("vite").Plugin | undefined;
@@ -13,7 +13,7 @@ const pwaErrorWithInstructions = "It seems that you're trying to build a PWA usi
13
13
  * @param {import('../types').userSettings} userSettings
14
14
  * @returns {import('vite').Plugin | undefined}
15
15
  */
16
- export const needlePWA = (command, config, userSettings) => {
16
+ export function needlePWA(command, config, userSettings) {
17
17
  // @ts-ignore // TODO correctly type the userSettings.pwaOptions object
18
18
  /** @type {import("vite-plugin-pwa").VitePWAOptions | false} */
19
19
  const pwaOptions = userSettings.pwa === true
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1,7 @@
1
+ /**
2
+ * @param {"build" | "serve"} command
3
+ * @param {import('../types/needleConfig').needleMeta | null} config
4
+ * @param {import('../types').userSettings} userSettings
5
+ * @returns {import('vite').Plugin | undefined}
6
+ */
1
7
  export function needleReload(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null, userSettings: import("../types").userSettings): import("vite").Plugin | undefined;
@@ -20,7 +20,7 @@ let assetsDirectory = "";
20
20
  * @param {import('../types').userSettings} userSettings
21
21
  * @returns {import('vite').Plugin | undefined}
22
22
  */
23
- export const needleReload = (command, config, userSettings) => {
23
+ export function needleReload(command, config, userSettings) {
24
24
  if (command === "build") return undefined;
25
25
 
26
26
  if (userSettings?.noReload === true) return undefined;
@@ -1 +1,7 @@
1
+ /** Can open the network server in the browser.
2
+ * @param {"build" | "serve"} command
3
+ * @param {import('../types').needleMeta | null} config
4
+ * @param {import('../types').userSettings} userSettings
5
+ * @returns {import('vite').Plugin}
6
+ */
1
7
  export function needleServer(command: "build" | "serve", config: import("../types").needleMeta | null, userSettings: import("../types").userSettings): import("vite").Plugin;
@@ -4,7 +4,7 @@
4
4
  * @param {import('../types').userSettings} userSettings
5
5
  * @returns {import('vite').Plugin}
6
6
  */
7
- export const needleServer = (command, config, userSettings) => {
7
+ export function needleServer(command, config, userSettings) {
8
8
 
9
9
  const shouldOpenBrowser = userSettings.openBrowser === true;
10
10
 
@@ -64,4 +64,4 @@ export const needleServer = (command, config, userSettings) => {
64
64
  }
65
65
  },
66
66
  }
67
- };
67
+ }
@@ -1 +1,8 @@
1
+ /** Modify the glb load path in codegen files.
2
+ * This is necessary if the assets directory is not the default (changed by the user in needle.config.json).
3
+ * @param {"build" | "serve"} command
4
+ * @param {import('../types/needleConfig').needleMeta | null | undefined} config
5
+ * @param {import('../types').userSettings} userSettings
6
+ * @returns {import('vite').Plugin | undefined}
7
+ */
1
8
  export function needleTransformCodegen(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin | undefined;
@@ -7,7 +7,7 @@ import { builtAssetsDirectory, tryLoadProjectConfig } from './config.js';
7
7
  * @param {import('../types').userSettings} userSettings
8
8
  * @returns {import('vite').Plugin | undefined}
9
9
  */
10
- export const needleTransformCodegen = (command, config, userSettings) => {
10
+ export function needleTransformCodegen(command, config, userSettings) {
11
11
 
12
12
  if (config?.noCodegenTransform === true || userSettings?.noCodegenTransform === true) {
13
13
  return;
@@ -1 +1,5 @@
1
+ /**
2
+ * @param {import('../types').userSettings} userSettings
3
+ * @returns {import('vite').Plugin[]}
4
+ */
1
5
  export function needleTransformCode(command: any, config: any, userSettings: import("../types").userSettings): import("vite").Plugin[];
@@ -5,7 +5,7 @@
5
5
  * @param {import('../types').userSettings} userSettings
6
6
  * @returns {import('vite').Plugin[]}
7
7
  */
8
- export const needleTransformCode = (command, config, userSettings) => {
8
+ export function needleTransformCode(command, config, userSettings) {
9
9
 
10
10
  return [
11
11
  {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Make sure we dont have vite 4.4.x installed when needle engine is used locally
3
+ * @param {import('../types').userSettings} userSettings
4
+ */
1
5
  export function vite_4_4_hack(command: any, config: any, userSettings: import("../types").userSettings): {
2
6
  name: string;
3
7
  configureServer(server: any): Promise<void>;
@@ -6,7 +6,7 @@ import { execSync } from 'child_process';
6
6
  * Make sure we dont have vite 4.4.x installed when needle engine is used locally
7
7
  * @param {import('../types').userSettings} userSettings
8
8
  */
9
- export const vite_4_4_hack = (command, config, userSettings) => {
9
+ export function vite_4_4_hack(command, config, userSettings) {
10
10
  if (userSettings.vite44Hack === false) return;
11
11
  return {
12
12
  name: "needle-vite-4.4-hack",
@@ -8,16 +8,17 @@ export enum EventType {
8
8
  PointerDown = 2,
9
9
  PointerUp = 3,
10
10
  PointerClick = 4,
11
- Drag = 5,
12
- Drop = 6,
13
- Scroll = 7,
14
- UpdateSelected = 8,
15
- Select = 9,
16
- Deselect = 10,
17
- Move = 11,
18
- InitializePotentialDrag = 12,
19
- BeginDrag = 13,
20
- EndDrag = 14,
21
- Submit = 15,
22
- Cancel = 16
11
+ // Unity Events, not currently supported:
12
+ //Drag = 5,
13
+ //Drop = 6,
14
+ //Scroll = 7,
15
+ //UpdateSelected = 8,
16
+ //Select = 9,
17
+ //Deselect = 10,
18
+ //Move = 11,
19
+ //InitializePotentialDrag = 12,
20
+ //BeginDrag = 13,
21
+ //EndDrag = 14,
22
+ //Submit = 15,
23
+ //Cancel = 16
23
24
  }
@@ -1,19 +1,21 @@
1
1
  import { Box3, Color, CubeTexture, EquirectangularReflectionMapping, LinearSRGBColorSpace, LineSegments, Material, Object3D, Quaternion, Texture, Vector3 } from "three";
2
2
 
3
+ import { CreateWireCube } from "../engine/engine_gizmos.js";
3
4
  import { MaterialPropertyBlock } from "../engine/engine_materialpropertyblock.js";
4
5
  import { loadPMREM } from "../engine/engine_pmrem.js";
5
6
  import { serializable } from "../engine/engine_serialization.js";
6
7
  import { Context } from "../engine/engine_setup.js";
8
+ import { getBoundingBox, getWorldPosition } from "../engine/engine_three_utils.js";
7
9
  import { getParam, resolveUrl } from "../engine/engine_utils.js";
8
- import { BoxHelperComponent } from "./BoxHelperComponent.js";
9
10
  import { Behaviour } from "./Component.js";
10
11
  import { EventList } from "./EventList.js";
11
- import { getBoundingBox, getWorldPosition } from "../engine/engine_three_utils.js";
12
- import { CreateWireCube } from "../engine/engine_gizmos.js";
13
12
 
14
13
  export const debug = getParam("debugreflectionprobe");
15
14
  const disable = getParam("noreflectionprobe");
16
15
 
16
+ let box: Box3 | null = null;
17
+ const _identityRotation = new Quaternion();
18
+
17
19
  const $reflectionProbeKey = Symbol("reflectionProbeKey");
18
20
  /**
19
21
  * The [ReflectionProbe](https://engine.needle.tools/docs/api/ReflectionProbe) provides environment reflection data to materials within its defined area.
@@ -42,13 +44,11 @@ const $reflectionProbeKey = Symbol("reflectionProbeKey");
42
44
  export class ReflectionProbe extends Behaviour {
43
45
 
44
46
  private static _probes: Map<Context, ReflectionProbe[]> = new Map();
45
- /** The bounding box for this component */
46
- private box: Box3 | null = null;
47
47
  private static testBox: Box3 = new Box3();
48
- private static _identityRotation: Quaternion = new Quaternion();
49
48
 
50
49
  /**
51
- * Checks if the given material is currently using a reflection probe. This is determined by checking for an override on the material's "envMap" property, which is set by the Renderer component when applying a reflection probe.
50
+ * Checks if the given material is currently using a reflection probe.
51
+ * This is determined by checking for an override on the material's "envMap" property, which is set by the Renderer component when applying a reflection probe.
52
52
  */
53
53
  static isUsingReflectionProbe(material: Material) {
54
54
  return !!(material as any)[$reflectionProbeKey];
@@ -106,14 +106,17 @@ export class ReflectionProbe extends Behaviour {
106
106
  private _textureUrlInFlight?: string;
107
107
 
108
108
  /**
109
- * The cubemap or HDR texture used for reflections. Can be assigned directly or via a URL string. When assigning via URL, the texture will be loaded asynchronously and applied once ready.
109
+ * The cubemap or HDR texture used for reflections. Can be assigned directly or via a URL string.
110
+ * When assigning via URL, the texture will be loaded asynchronously and applied once ready.
111
+ * @param tex The texture or URL to assign to this reflection probe
112
+ * @default null
110
113
  */
111
114
  @serializable([Texture, String])
112
115
  set texture(tex: Texture | null) {
113
116
  if (this._texture === tex) return;
114
117
 
115
118
  if (typeof tex === "string") {
116
- if(debug) console.debug(`[ReflectionProbe] Loading reflection probe texture from URL: ${tex}`);
119
+ if (debug) console.debug(`[ReflectionProbe] Loading reflection probe texture from URL: ${tex}`);
117
120
  this._textureUrlInFlight = tex;
118
121
  const textureUrl = resolveUrl(this.sourceId, tex);
119
122
  loadPMREM(textureUrl, this.context.renderer).then(loaded => {
@@ -129,7 +132,7 @@ export class ReflectionProbe extends Behaviour {
129
132
  // During deserialization / loading of the GLB the deserializer sets an empty DataTexture
130
133
  // But if the texture is serialized as a string (via Blender Reflection Probes) then the async loading above
131
134
  // Will abort IF textureInFlight is reset (here). That's why we do NOT reset textureInFlight during initialization (when __didAwake is false). Only after awake, when we are sure that the async loading is done, we reset the in-flight URL to allow new assignments.
132
- if(this.__didAwake) this._textureUrlInFlight = undefined;
135
+ if (this.__didAwake) this._textureUrlInFlight = undefined;
133
136
 
134
137
  this._texture = tex;
135
138
 
@@ -149,17 +152,26 @@ export class ReflectionProbe extends Behaviour {
149
152
  return this._texture;
150
153
  }
151
154
 
155
+ /**
156
+ * The intensity of the reflection probe's influence.
157
+ * Higher values will make reflections brighter, while lower values will make them dimmer.
158
+ * The default value is 1, which means the reflections will be applied at their original brightness. Adjust this value to achieve the desired look for your scene.
159
+ * @default 1
160
+ */
152
161
  @serializable()
153
162
  intensity: number = 1;
154
163
 
155
164
  /**
156
- * Defines the center and size of the reflection probe's influence area.
165
+ * Defines the center of the reflection probe's influence area relative to the GameObject's position.
166
+ * The probe will affect objects within a box defined by this center and the `size` property.
167
+ * Note: The actual influence area is determined by both the `center` and `size` properties. The `center` defines the offset from the GameObject's position, while the `size` defines the dimensions of the box around that center. Objects within this box will be influenced by the reflection probe.
157
168
  */
158
169
  @serializable(Vector3)
159
170
  center: Vector3 = new Vector3();
160
171
 
161
172
  /**
162
- * Defines the size of the reflection probe's influence area. Objects within this box will be affected by the probe's reflections.
173
+ * Defines the size of the reflection probe's influence area. Objects within this box will be affected by the probe's reflections.
174
+ * Note: The actual influence area is determined by both the `center` and `size` properties. The `center` defines the offset from the GameObject's position, while the `size` defines the dimensions of the box around that center. Objects within this box will be influenced by the reflection probe.
163
175
  */
164
176
  @serializable(Vector3)
165
177
  size: Vector3 = new Vector3(1, 1, 1);
@@ -172,16 +184,16 @@ export class ReflectionProbe extends Behaviour {
172
184
 
173
185
  private isInBox(obj: Object3D) {
174
186
 
175
- this.box ??= new Box3();
176
- this.box!.setFromCenterAndSize(this.gameObject.worldPosition.add(this.center), this.gameObject.worldScale.multiply(this.size));
187
+ box ??= new Box3();
188
+ box!.setFromCenterAndSize(this.gameObject.worldPosition.add(this.center), this.gameObject.worldScale.multiply(this.size));
177
189
 
178
190
  getBoundingBox([obj], undefined, undefined, ReflectionProbe.testBox);
179
191
 
180
192
  if (ReflectionProbe.testBox.isEmpty()) {
181
- return this.box.containsPoint(obj.worldPosition);
193
+ return box.containsPoint(obj.worldPosition);
182
194
  }
183
195
  else {
184
- return this.box?.intersectsBox(ReflectionProbe.testBox);
196
+ return box?.intersectsBox(ReflectionProbe.testBox);
185
197
  }
186
198
  }
187
199
 
@@ -215,7 +227,7 @@ export class ReflectionProbe extends Behaviour {
215
227
  if (this._gizmo) {
216
228
  if (this.center) this._gizmo.position.copy(this.center);
217
229
  if (this.size) this._gizmo.scale.copy(this.size);
218
- this._gizmo.worldQuaternion = ReflectionProbe._identityRotation;
230
+ this._gizmo.worldQuaternion = _identityRotation.identity();
219
231
  }
220
232
  }
221
233
 
@@ -248,7 +260,10 @@ export class ReflectionProbe extends Behaviour {
248
260
  }
249
261
 
250
262
  /**
251
- * Applies this reflection probe to the given object by setting material property overrides for "envMap", "envMapRotation", and "envMapIntensity". This is typically called by the Renderer component when determining which reflection probe to use for a given object.
263
+ * Applies this reflection probe to the given object by setting material property overrides for "envMap", "envMapRotation", and "envMapIntensity".
264
+ * This is typically called by the Renderer component when determining which reflection probe to use for a given object.
265
+ * @param object The object to apply the reflection probe to
266
+ * @see {@link unapply} for the corresponding method to remove the probe's influence from an object.
252
267
  */
253
268
  apply(object: Object3D) {
254
269
  if (disable) return;
@@ -267,7 +282,10 @@ export class ReflectionProbe extends Behaviour {
267
282
  }
268
283
 
269
284
  /**
270
- * Removes the reflection probe overrides from the given object. This is typically called by the Renderer component when an object is no longer influenced by this probe or when the probe is disabled.
285
+ * Removes the reflection probe overrides from the given object.
286
+ * This is typically called by the Renderer component when an object is no longer influenced by this probe or when the probe is disabled.
287
+ * @param object The object to remove the reflection probe overrides from
288
+ * @see {@link apply} for the corresponding method to apply the probe's influence to an object.
271
289
  */
272
290
  unapply(obj: Object3D) {
273
291
  const block = MaterialPropertyBlock.get(obj);