@scenography/plugin-model 0.6.0 → 0.7.0

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.
@@ -13,7 +13,8 @@ const validateModel = (model) => (0, _scenography_scene.validate)([
13
13
  const modelData = {
14
14
  kind: "models",
15
15
  cardinality: "many",
16
- validate: (model) => validateModel(model)
16
+ validate: (model) => validateModel(model),
17
+ assets: (model) => [model.src]
17
18
  };
18
19
  //#endregion
19
20
  Object.defineProperty(exports, "modelData", {
@@ -29,4 +30,4 @@ Object.defineProperty(exports, "validateModel", {
29
30
  }
30
31
  });
31
32
 
32
- //# sourceMappingURL=data-tK2hlhyq.cjs.map
33
+ //# sourceMappingURL=data-D-pEUime.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-tK2hlhyq.cjs","names":["isVec3"],"sources":["../src/data/validate.ts","../src/data/plugin.ts"],"sourcesContent":["import {\n existsProp,\n isFiniteNumber,\n isVec3,\n propIs,\n validate,\n type ValidationResult,\n} from \"@scenography/scene\";\n\nimport type { Model } from \"./model\";\n\nexport const validateModel = (model: Model): ValidationResult =>\n validate<Model>([\n existsProp(\"id\", \"Model is missing an id.\"),\n existsProp(\"src\", \"Model is missing a src.\"),\n propIs(\"position\", isVec3, \"position must be a [x, y, z] triple.\"),\n propIs(\"rotation\", isVec3, \"rotation must be a [x, y, z] triple.\"),\n propIs(\n \"scale\",\n (v) => isFiniteNumber(v) || isVec3(v),\n \"scale must be a number or a [x, y, z] triple.\",\n ),\n ])(model);\n","import type { DataPlugin } from \"@scenography/scene\";\n\nimport { validateModel } from \"./validate\";\nimport type { Model } from \"./model\";\n\n/** The data half of the model plugin: owns the `models` scene key (a collection). */\nexport const modelData: DataPlugin<Model> = {\n kind: \"models\",\n cardinality: \"many\",\n validate: (model) => validateModel(model),\n};\n"],"mappings":";;AAWA,MAAa,iBAAiB,WAAA,GAAA,mBAAA,SAAA,CACZ;oCACH,MAAM,yBAAyB;oCAC/B,OAAO,yBAAyB;gCACpC,YAAYA,mBAAAA,QAAQ,sCAAsC;gCAC1D,YAAYA,mBAAAA,QAAQ,sCAAsC;gCAE/D,UACC,OAAA,GAAA,mBAAA,eAAA,CAAqB,CAAC,MAAA,GAAA,mBAAA,OAAA,CAAY,CAAC,GACpC,+CACF;AACF,CAAC,CAAC,CAAC,KAAK;;;;AChBV,MAAa,YAA+B;CAC1C,MAAM;CACN,aAAa;CACb,WAAW,UAAU,cAAc,KAAK;AAC1C"}
1
+ {"version":3,"file":"data-D-pEUime.cjs","names":["isVec3"],"sources":["../src/data/validate.ts","../src/data/plugin.ts"],"sourcesContent":["import {\n existsProp,\n isFiniteNumber,\n isVec3,\n propIs,\n validate,\n type ValidationResult,\n} from \"@scenography/scene\";\n\nimport type { Model } from \"./model\";\n\nexport const validateModel = (model: Model): ValidationResult =>\n validate<Model>([\n existsProp(\"id\", \"Model is missing an id.\"),\n existsProp(\"src\", \"Model is missing a src.\"),\n propIs(\"position\", isVec3, \"position must be a [x, y, z] triple.\"),\n propIs(\"rotation\", isVec3, \"rotation must be a [x, y, z] triple.\"),\n propIs(\n \"scale\",\n (v) => isFiniteNumber(v) || isVec3(v),\n \"scale must be a number or a [x, y, z] triple.\",\n ),\n ])(model);\n","import type { DataPlugin } from \"@scenography/scene\";\n\nimport { validateModel } from \"./validate\";\nimport type { Model } from \"./model\";\n\n/** The data half of the model plugin: owns the `models` scene key (a collection). */\nexport const modelData: DataPlugin<Model> = {\n kind: \"models\",\n cardinality: \"many\",\n validate: (model) => validateModel(model),\n assets: (model) => [model.src],\n};\n"],"mappings":";;AAWA,MAAa,iBAAiB,WAAA,GAAA,mBAAA,SAAA,CACZ;oCACH,MAAM,yBAAyB;oCAC/B,OAAO,yBAAyB;gCACpC,YAAYA,mBAAAA,QAAQ,sCAAsC;gCAC1D,YAAYA,mBAAAA,QAAQ,sCAAsC;gCAE/D,UACC,OAAA,GAAA,mBAAA,eAAA,CAAqB,CAAC,MAAA,GAAA,mBAAA,OAAA,CAAY,CAAC,GACpC,+CACF;AACF,CAAC,CAAC,CAAC,KAAK;;;;AChBV,MAAa,YAA+B;CAC1C,MAAM;CACN,aAAa;CACb,WAAW,UAAU,cAAc,KAAK;CACxC,SAAS,UAAU,CAAC,MAAM,GAAG;AAC/B"}
@@ -13,9 +13,10 @@ const validateModel = (model) => validate([
13
13
  const modelData = {
14
14
  kind: "models",
15
15
  cardinality: "many",
16
- validate: (model) => validateModel(model)
16
+ validate: (model) => validateModel(model),
17
+ assets: (model) => [model.src]
17
18
  };
18
19
  //#endregion
19
20
  export { validateModel as n, modelData as t };
20
21
 
21
- //# sourceMappingURL=data-CHJeJEc2.mjs.map
22
+ //# sourceMappingURL=data-DwYdV0WA.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-CHJeJEc2.mjs","names":[],"sources":["../src/data/validate.ts","../src/data/plugin.ts"],"sourcesContent":["import {\n existsProp,\n isFiniteNumber,\n isVec3,\n propIs,\n validate,\n type ValidationResult,\n} from \"@scenography/scene\";\n\nimport type { Model } from \"./model\";\n\nexport const validateModel = (model: Model): ValidationResult =>\n validate<Model>([\n existsProp(\"id\", \"Model is missing an id.\"),\n existsProp(\"src\", \"Model is missing a src.\"),\n propIs(\"position\", isVec3, \"position must be a [x, y, z] triple.\"),\n propIs(\"rotation\", isVec3, \"rotation must be a [x, y, z] triple.\"),\n propIs(\n \"scale\",\n (v) => isFiniteNumber(v) || isVec3(v),\n \"scale must be a number or a [x, y, z] triple.\",\n ),\n ])(model);\n","import type { DataPlugin } from \"@scenography/scene\";\n\nimport { validateModel } from \"./validate\";\nimport type { Model } from \"./model\";\n\n/** The data half of the model plugin: owns the `models` scene key (a collection). */\nexport const modelData: DataPlugin<Model> = {\n kind: \"models\",\n cardinality: \"many\",\n validate: (model) => validateModel(model),\n};\n"],"mappings":";;AAWA,MAAa,iBAAiB,UAC5B,SAAgB;CACd,WAAW,MAAM,yBAAyB;CAC1C,WAAW,OAAO,yBAAyB;CAC3C,OAAO,YAAY,QAAQ,sCAAsC;CACjE,OAAO,YAAY,QAAQ,sCAAsC;CACjE,OACE,UACC,MAAM,eAAe,CAAC,KAAK,OAAO,CAAC,GACpC,+CACF;AACF,CAAC,CAAC,CAAC,KAAK;;;;AChBV,MAAa,YAA+B;CAC1C,MAAM;CACN,aAAa;CACb,WAAW,UAAU,cAAc,KAAK;AAC1C"}
1
+ {"version":3,"file":"data-DwYdV0WA.mjs","names":[],"sources":["../src/data/validate.ts","../src/data/plugin.ts"],"sourcesContent":["import {\n existsProp,\n isFiniteNumber,\n isVec3,\n propIs,\n validate,\n type ValidationResult,\n} from \"@scenography/scene\";\n\nimport type { Model } from \"./model\";\n\nexport const validateModel = (model: Model): ValidationResult =>\n validate<Model>([\n existsProp(\"id\", \"Model is missing an id.\"),\n existsProp(\"src\", \"Model is missing a src.\"),\n propIs(\"position\", isVec3, \"position must be a [x, y, z] triple.\"),\n propIs(\"rotation\", isVec3, \"rotation must be a [x, y, z] triple.\"),\n propIs(\n \"scale\",\n (v) => isFiniteNumber(v) || isVec3(v),\n \"scale must be a number or a [x, y, z] triple.\",\n ),\n ])(model);\n","import type { DataPlugin } from \"@scenography/scene\";\n\nimport { validateModel } from \"./validate\";\nimport type { Model } from \"./model\";\n\n/** The data half of the model plugin: owns the `models` scene key (a collection). */\nexport const modelData: DataPlugin<Model> = {\n kind: \"models\",\n cardinality: \"many\",\n validate: (model) => validateModel(model),\n assets: (model) => [model.src],\n};\n"],"mappings":";;AAWA,MAAa,iBAAiB,UAC5B,SAAgB;CACd,WAAW,MAAM,yBAAyB;CAC1C,WAAW,OAAO,yBAAyB;CAC3C,OAAO,YAAY,QAAQ,sCAAsC;CACjE,OAAO,YAAY,QAAQ,sCAAsC;CACjE,OACE,UACC,MAAM,eAAe,CAAC,KAAK,OAAO,CAAC,GACpC,+CACF;AACF,CAAC,CAAC,CAAC,KAAK;;;;AChBV,MAAa,YAA+B;CAC1C,MAAM;CACN,aAAa;CACb,WAAW,UAAU,cAAc,KAAK;CACxC,SAAS,UAAU,CAAC,MAAM,GAAG;AAC/B"}
package/dist/data.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_data = require("./data-tK2hlhyq.cjs");
2
+ const require_data = require("./data-D-pEUime.cjs");
3
3
  exports.modelData = require_data.modelData;
4
4
  exports.validateModel = require_data.validateModel;
package/dist/data.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as validateModel, t as modelData } from "./data-CHJeJEc2.mjs";
1
+ import { n as validateModel, t as modelData } from "./data-DwYdV0WA.mjs";
2
2
  export { modelData, validateModel };
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_data = require("./data-tK2hlhyq.cjs");
2
+ const require_data = require("./data-D-pEUime.cjs");
3
3
  let three = require("three");
4
4
  let _scenography_engine = require("@scenography/engine");
5
5
  //#region src/buildModel.ts
@@ -29,12 +29,13 @@ function buildModel(model) {
29
29
  loader.setMeshoptDecoder(MeshoptDecoder);
30
30
  if (ktx2Loader) loader.setKTX2Loader(ktx2Loader);
31
31
  loader.load(model.src, (gltf) => {
32
+ (0, _scenography_engine.trackAsset)(model.src);
32
33
  gltf.scene.traverse((child) => {
33
34
  child.castShadow = true;
34
35
  child.receiveShadow = true;
35
36
  });
36
37
  group.add(gltf.scene);
37
- });
38
+ }, void 0, () => (0, _scenography_engine.trackAsset)(model.src));
38
39
  });
39
40
  return group;
40
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["Group","modelData"],"sources":["../src/buildModel.ts","../src/plugin.ts"],"sourcesContent":["import { Group, type Object3D } from \"three\";\nimport { getKtx2Loader } from \"@scenography/engine\";\n\nimport type { Model } from \"./data\";\n\n/**\n * Build the three.js object for an external `Model`. Returns an empty `Group`\n * with the transform applied immediately; the glTF/GLB is fetched async and its\n * scene added once ready (same pattern as texture loading). `GLTFLoader` is\n * imported on demand so it only ships in the bundle when a scene uses models;\n * the meshopt decoder rides along so `EXT_meshopt_compression` models load, and\n * the shared KTX2 loader handles `KHR_texture_basisu` maps.\n */\nexport function buildModel(model: Model): Object3D {\n const group = new Group();\n group.name = `model:${model.id}`;\n group.userData.scenographyId = model.id;\n\n if (model.position) group.position.set(...model.position);\n if (model.rotation) group.rotation.set(...model.rotation);\n if (model.scale !== undefined) {\n if (typeof model.scale === \"number\") group.scale.setScalar(model.scale);\n else group.scale.set(...model.scale);\n }\n\n const ktx2 = getKtx2Loader();\n void Promise.all([\n import(\"three/examples/jsm/loaders/GLTFLoader.js\"),\n import(\"three/examples/jsm/libs/meshopt_decoder.module.js\"),\n ktx2 ?? Promise.resolve(null),\n ]).then(([{ GLTFLoader }, { MeshoptDecoder }, ktx2Loader]) => {\n const loader = new GLTFLoader();\n loader.setMeshoptDecoder(MeshoptDecoder);\n if (ktx2Loader) loader.setKTX2Loader(ktx2Loader as Parameters<typeof loader.setKTX2Loader>[0]);\n loader.load(model.src, (gltf) => {\n gltf.scene.traverse((child) => {\n child.castShadow = true;\n child.receiveShadow = true;\n });\n group.add(gltf.scene);\n });\n });\n\n return group;\n}\n","import type { EnginePlugin } from \"@scenography/engine\";\n\nimport { buildModel } from \"./buildModel\";\nimport { modelData, type Model } from \"./data\";\n\n/** The model plugin: places each external glTF/GLB `Model` in the scene. */\nexport const model = (): EnginePlugin<Model> => ({\n data: modelData,\n build: (definition) => ({ object: buildModel(definition) }),\n});\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,WAAW,OAAwB;CACjD,MAAM,QAAQ,IAAIA,MAAAA,MAAM;CACxB,MAAM,OAAO,SAAS,MAAM;CAC5B,MAAM,SAAS,gBAAgB,MAAM;CAErC,IAAI,MAAM,UAAU,MAAM,SAAS,IAAI,GAAG,MAAM,QAAQ;CACxD,IAAI,MAAM,UAAU,MAAM,SAAS,IAAI,GAAG,MAAM,QAAQ;CACxD,IAAI,MAAM,UAAU,KAAA,GAClB,IAAI,OAAO,MAAM,UAAU,UAAU,MAAM,MAAM,UAAU,MAAM,KAAK;MACjE,MAAM,MAAM,IAAI,GAAG,MAAM,KAAK;CAGrC,MAAM,QAAA,GAAA,oBAAA,cAAA,CAAqB;CAC3B,QAAa,IAAI;EACf,OAAO;EACP,OAAO;EACP,QAAQ,QAAQ,QAAQ,IAAI;CAC9B,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,kBAAkB,gBAAgB;EAC5D,MAAM,SAAS,IAAI,WAAW;EAC9B,OAAO,kBAAkB,cAAc;EACvC,IAAI,YAAY,OAAO,cAAc,UAAwD;EAC7F,OAAO,KAAK,MAAM,MAAM,SAAS;GAC/B,KAAK,MAAM,UAAU,UAAU;IAC7B,MAAM,aAAa;IACnB,MAAM,gBAAgB;GACxB,CAAC;GACD,MAAM,IAAI,KAAK,KAAK;EACtB,CAAC;CACH,CAAC;CAED,OAAO;AACT;;;;ACtCA,MAAa,eAAoC;CAC/C,MAAMC,aAAAA;CACN,QAAQ,gBAAgB,EAAE,QAAQ,WAAW,UAAU,EAAE;AAC3D"}
1
+ {"version":3,"file":"index.cjs","names":["Group","modelData"],"sources":["../src/buildModel.ts","../src/plugin.ts"],"sourcesContent":["import { Group, type Object3D } from \"three\";\nimport { getKtx2Loader, trackAsset } from \"@scenography/engine\";\n\nimport type { Model } from \"./data\";\n\n/**\n * Build the three.js object for an external `Model`. Returns an empty `Group`\n * with the transform applied immediately; the glTF/GLB is fetched async and its\n * scene added once ready (same pattern as texture loading). `GLTFLoader` is\n * imported on demand so it only ships in the bundle when a scene uses models;\n * the meshopt decoder rides along so `EXT_meshopt_compression` models load, and\n * the shared KTX2 loader handles `KHR_texture_basisu` maps.\n */\nexport function buildModel(model: Model): Object3D {\n const group = new Group();\n group.name = `model:${model.id}`;\n group.userData.scenographyId = model.id;\n\n if (model.position) group.position.set(...model.position);\n if (model.rotation) group.rotation.set(...model.rotation);\n if (model.scale !== undefined) {\n if (typeof model.scale === \"number\") group.scale.setScalar(model.scale);\n else group.scale.set(...model.scale);\n }\n\n const ktx2 = getKtx2Loader();\n void Promise.all([\n import(\"three/examples/jsm/loaders/GLTFLoader.js\"),\n import(\"three/examples/jsm/libs/meshopt_decoder.module.js\"),\n ktx2 ?? Promise.resolve(null),\n ]).then(([{ GLTFLoader }, { MeshoptDecoder }, ktx2Loader]) => {\n const loader = new GLTFLoader();\n loader.setMeshoptDecoder(MeshoptDecoder);\n if (ktx2Loader) loader.setKTX2Loader(ktx2Loader as Parameters<typeof loader.setKTX2Loader>[0]);\n loader.load(\n model.src,\n (gltf) => {\n trackAsset(model.src);\n gltf.scene.traverse((child) => {\n child.castShadow = true;\n child.receiveShadow = true;\n });\n group.add(gltf.scene);\n },\n undefined,\n () => trackAsset(model.src),\n );\n });\n\n return group;\n}\n","import type { EnginePlugin } from \"@scenography/engine\";\n\nimport { buildModel } from \"./buildModel\";\nimport { modelData, type Model } from \"./data\";\n\n/** The model plugin: places each external glTF/GLB `Model` in the scene. */\nexport const model = (): EnginePlugin<Model> => ({\n data: modelData,\n build: (definition) => ({ object: buildModel(definition) }),\n});\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,WAAW,OAAwB;CACjD,MAAM,QAAQ,IAAIA,MAAAA,MAAM;CACxB,MAAM,OAAO,SAAS,MAAM;CAC5B,MAAM,SAAS,gBAAgB,MAAM;CAErC,IAAI,MAAM,UAAU,MAAM,SAAS,IAAI,GAAG,MAAM,QAAQ;CACxD,IAAI,MAAM,UAAU,MAAM,SAAS,IAAI,GAAG,MAAM,QAAQ;CACxD,IAAI,MAAM,UAAU,KAAA,GAClB,IAAI,OAAO,MAAM,UAAU,UAAU,MAAM,MAAM,UAAU,MAAM,KAAK;MACjE,MAAM,MAAM,IAAI,GAAG,MAAM,KAAK;CAGrC,MAAM,QAAA,GAAA,oBAAA,cAAA,CAAqB;CAC3B,QAAa,IAAI;EACf,OAAO;EACP,OAAO;EACP,QAAQ,QAAQ,QAAQ,IAAI;CAC9B,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,kBAAkB,gBAAgB;EAC5D,MAAM,SAAS,IAAI,WAAW;EAC9B,OAAO,kBAAkB,cAAc;EACvC,IAAI,YAAY,OAAO,cAAc,UAAwD;EAC7F,OAAO,KACL,MAAM,MACL,SAAS;GACR,CAAA,GAAA,oBAAA,WAAA,CAAW,MAAM,GAAG;GACpB,KAAK,MAAM,UAAU,UAAU;IAC7B,MAAM,aAAa;IACnB,MAAM,gBAAgB;GACxB,CAAC;GACD,MAAM,IAAI,KAAK,KAAK;EACtB,GACA,KAAA,UAAA,GAAA,oBAAA,WAAA,CACiB,MAAM,GAAG,CAC5B;CACF,CAAC;CAED,OAAO;AACT;;;;AC5CA,MAAa,eAAoC;CAC/C,MAAMC,aAAAA;CACN,QAAQ,gBAAgB,EAAE,QAAQ,WAAW,UAAU,EAAE;AAC3D"}
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { n as validateModel, t as modelData } from "./data-CHJeJEc2.mjs";
1
+ import { n as validateModel, t as modelData } from "./data-DwYdV0WA.mjs";
2
2
  import { Group } from "three";
3
- import { getKtx2Loader } from "@scenography/engine";
3
+ import { getKtx2Loader, trackAsset } from "@scenography/engine";
4
4
  //#region src/buildModel.ts
5
5
  /**
6
6
  * Build the three.js object for an external `Model`. Returns an empty `Group`
@@ -28,12 +28,13 @@ function buildModel(model) {
28
28
  loader.setMeshoptDecoder(MeshoptDecoder);
29
29
  if (ktx2Loader) loader.setKTX2Loader(ktx2Loader);
30
30
  loader.load(model.src, (gltf) => {
31
+ trackAsset(model.src);
31
32
  gltf.scene.traverse((child) => {
32
33
  child.castShadow = true;
33
34
  child.receiveShadow = true;
34
35
  });
35
36
  group.add(gltf.scene);
36
- });
37
+ }, void 0, () => trackAsset(model.src));
37
38
  });
38
39
  return group;
39
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/buildModel.ts","../src/plugin.ts"],"sourcesContent":["import { Group, type Object3D } from \"three\";\nimport { getKtx2Loader } from \"@scenography/engine\";\n\nimport type { Model } from \"./data\";\n\n/**\n * Build the three.js object for an external `Model`. Returns an empty `Group`\n * with the transform applied immediately; the glTF/GLB is fetched async and its\n * scene added once ready (same pattern as texture loading). `GLTFLoader` is\n * imported on demand so it only ships in the bundle when a scene uses models;\n * the meshopt decoder rides along so `EXT_meshopt_compression` models load, and\n * the shared KTX2 loader handles `KHR_texture_basisu` maps.\n */\nexport function buildModel(model: Model): Object3D {\n const group = new Group();\n group.name = `model:${model.id}`;\n group.userData.scenographyId = model.id;\n\n if (model.position) group.position.set(...model.position);\n if (model.rotation) group.rotation.set(...model.rotation);\n if (model.scale !== undefined) {\n if (typeof model.scale === \"number\") group.scale.setScalar(model.scale);\n else group.scale.set(...model.scale);\n }\n\n const ktx2 = getKtx2Loader();\n void Promise.all([\n import(\"three/examples/jsm/loaders/GLTFLoader.js\"),\n import(\"three/examples/jsm/libs/meshopt_decoder.module.js\"),\n ktx2 ?? Promise.resolve(null),\n ]).then(([{ GLTFLoader }, { MeshoptDecoder }, ktx2Loader]) => {\n const loader = new GLTFLoader();\n loader.setMeshoptDecoder(MeshoptDecoder);\n if (ktx2Loader) loader.setKTX2Loader(ktx2Loader as Parameters<typeof loader.setKTX2Loader>[0]);\n loader.load(model.src, (gltf) => {\n gltf.scene.traverse((child) => {\n child.castShadow = true;\n child.receiveShadow = true;\n });\n group.add(gltf.scene);\n });\n });\n\n return group;\n}\n","import type { EnginePlugin } from \"@scenography/engine\";\n\nimport { buildModel } from \"./buildModel\";\nimport { modelData, type Model } from \"./data\";\n\n/** The model plugin: places each external glTF/GLB `Model` in the scene. */\nexport const model = (): EnginePlugin<Model> => ({\n data: modelData,\n build: (definition) => ({ object: buildModel(definition) }),\n});\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,WAAW,OAAwB;CACjD,MAAM,QAAQ,IAAI,MAAM;CACxB,MAAM,OAAO,SAAS,MAAM;CAC5B,MAAM,SAAS,gBAAgB,MAAM;CAErC,IAAI,MAAM,UAAU,MAAM,SAAS,IAAI,GAAG,MAAM,QAAQ;CACxD,IAAI,MAAM,UAAU,MAAM,SAAS,IAAI,GAAG,MAAM,QAAQ;CACxD,IAAI,MAAM,UAAU,KAAA,GAClB,IAAI,OAAO,MAAM,UAAU,UAAU,MAAM,MAAM,UAAU,MAAM,KAAK;MACjE,MAAM,MAAM,IAAI,GAAG,MAAM,KAAK;CAGrC,MAAM,OAAO,cAAc;CAC3B,QAAa,IAAI;EACf,OAAO;EACP,OAAO;EACP,QAAQ,QAAQ,QAAQ,IAAI;CAC9B,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,kBAAkB,gBAAgB;EAC5D,MAAM,SAAS,IAAI,WAAW;EAC9B,OAAO,kBAAkB,cAAc;EACvC,IAAI,YAAY,OAAO,cAAc,UAAwD;EAC7F,OAAO,KAAK,MAAM,MAAM,SAAS;GAC/B,KAAK,MAAM,UAAU,UAAU;IAC7B,MAAM,aAAa;IACnB,MAAM,gBAAgB;GACxB,CAAC;GACD,MAAM,IAAI,KAAK,KAAK;EACtB,CAAC;CACH,CAAC;CAED,OAAO;AACT;;;;ACtCA,MAAa,eAAoC;CAC/C,MAAM;CACN,QAAQ,gBAAgB,EAAE,QAAQ,WAAW,UAAU,EAAE;AAC3D"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/buildModel.ts","../src/plugin.ts"],"sourcesContent":["import { Group, type Object3D } from \"three\";\nimport { getKtx2Loader, trackAsset } from \"@scenography/engine\";\n\nimport type { Model } from \"./data\";\n\n/**\n * Build the three.js object for an external `Model`. Returns an empty `Group`\n * with the transform applied immediately; the glTF/GLB is fetched async and its\n * scene added once ready (same pattern as texture loading). `GLTFLoader` is\n * imported on demand so it only ships in the bundle when a scene uses models;\n * the meshopt decoder rides along so `EXT_meshopt_compression` models load, and\n * the shared KTX2 loader handles `KHR_texture_basisu` maps.\n */\nexport function buildModel(model: Model): Object3D {\n const group = new Group();\n group.name = `model:${model.id}`;\n group.userData.scenographyId = model.id;\n\n if (model.position) group.position.set(...model.position);\n if (model.rotation) group.rotation.set(...model.rotation);\n if (model.scale !== undefined) {\n if (typeof model.scale === \"number\") group.scale.setScalar(model.scale);\n else group.scale.set(...model.scale);\n }\n\n const ktx2 = getKtx2Loader();\n void Promise.all([\n import(\"three/examples/jsm/loaders/GLTFLoader.js\"),\n import(\"three/examples/jsm/libs/meshopt_decoder.module.js\"),\n ktx2 ?? Promise.resolve(null),\n ]).then(([{ GLTFLoader }, { MeshoptDecoder }, ktx2Loader]) => {\n const loader = new GLTFLoader();\n loader.setMeshoptDecoder(MeshoptDecoder);\n if (ktx2Loader) loader.setKTX2Loader(ktx2Loader as Parameters<typeof loader.setKTX2Loader>[0]);\n loader.load(\n model.src,\n (gltf) => {\n trackAsset(model.src);\n gltf.scene.traverse((child) => {\n child.castShadow = true;\n child.receiveShadow = true;\n });\n group.add(gltf.scene);\n },\n undefined,\n () => trackAsset(model.src),\n );\n });\n\n return group;\n}\n","import type { EnginePlugin } from \"@scenography/engine\";\n\nimport { buildModel } from \"./buildModel\";\nimport { modelData, type Model } from \"./data\";\n\n/** The model plugin: places each external glTF/GLB `Model` in the scene. */\nexport const model = (): EnginePlugin<Model> => ({\n data: modelData,\n build: (definition) => ({ object: buildModel(definition) }),\n});\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,WAAW,OAAwB;CACjD,MAAM,QAAQ,IAAI,MAAM;CACxB,MAAM,OAAO,SAAS,MAAM;CAC5B,MAAM,SAAS,gBAAgB,MAAM;CAErC,IAAI,MAAM,UAAU,MAAM,SAAS,IAAI,GAAG,MAAM,QAAQ;CACxD,IAAI,MAAM,UAAU,MAAM,SAAS,IAAI,GAAG,MAAM,QAAQ;CACxD,IAAI,MAAM,UAAU,KAAA,GAClB,IAAI,OAAO,MAAM,UAAU,UAAU,MAAM,MAAM,UAAU,MAAM,KAAK;MACjE,MAAM,MAAM,IAAI,GAAG,MAAM,KAAK;CAGrC,MAAM,OAAO,cAAc;CAC3B,QAAa,IAAI;EACf,OAAO;EACP,OAAO;EACP,QAAQ,QAAQ,QAAQ,IAAI;CAC9B,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,kBAAkB,gBAAgB;EAC5D,MAAM,SAAS,IAAI,WAAW;EAC9B,OAAO,kBAAkB,cAAc;EACvC,IAAI,YAAY,OAAO,cAAc,UAAwD;EAC7F,OAAO,KACL,MAAM,MACL,SAAS;GACR,WAAW,MAAM,GAAG;GACpB,KAAK,MAAM,UAAU,UAAU;IAC7B,MAAM,aAAa;IACnB,MAAM,gBAAgB;GACxB,CAAC;GACD,MAAM,IAAI,KAAK,KAAK;EACtB,GACA,KAAA,SACM,WAAW,MAAM,GAAG,CAC5B;CACF,CAAC;CAED,OAAO;AACT;;;;AC5CA,MAAa,eAAoC;CAC/C,MAAM;CACN,QAAQ,gBAAgB,EAAE,QAAQ,WAAW,UAAU,EAAE;AAC3D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scenography/plugin-model",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Model plugin for scenography: external glTF/GLB models placed in the space.",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -33,16 +33,16 @@
33
33
  }
34
34
  },
35
35
  "dependencies": {
36
- "@scenography/scene": "0.6.0"
36
+ "@scenography/scene": "0.7.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/three": "^0.160.0",
40
40
  "three": "^0.160.0",
41
- "@scenography/engine": "0.6.0"
41
+ "@scenography/engine": "0.7.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "three": ">=0.160.0",
45
- "@scenography/engine": "0.6.0"
45
+ "@scenography/engine": "0.7.0"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "tsdown",