angular-three-plugin 4.0.0-next.34 → 4.0.0-next.36
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
|
@@ -70,22 +70,19 @@ export class <%= className %> {
|
|
|
70
70
|
modelRef = viewChild<ElementRef<Group>>('model');
|
|
71
71
|
|
|
72
72
|
protected gltf = injectGLTF<<%= gltfResultTypeName %>>(() => ${options.importattribute && !url.startsWith("http") ? gltfName : `"${url}"`}${gltfOptions ? `, ${JSON.stringify(gltfOptions)}` : ""});
|
|
73
|
+
protected gltf = injectGLTF<<%= gltfResultTypeName %>>(() => <% if (useImportAttribute) { %> <%= gltfName %> <% } else { %> '<%= url %>' <% } %><% if (gltfOptions) { %>, <%= gltfOptions %><% } %>);
|
|
73
74
|
|
|
74
75
|
constructor() {
|
|
75
76
|
extend({ Group${ngtTypesArr.length ? ", " + ngtTypesArr.join(", ") : ""} });
|
|
77
|
+
extend({ Group<%= threeImports %> });
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
hasAnimations
|
|
79
|
-
? `
|
|
79
|
+
<% if (animations.length) { %>
|
|
80
80
|
const animations = injectAnimations(this.gltf, this.modelRef);
|
|
81
81
|
effect(() => {
|
|
82
|
-
if (animations
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
`
|
|
87
|
-
: ""
|
|
88
|
-
}
|
|
82
|
+
if (!animations.isReady) return;
|
|
83
|
+
this.animations.set(animations);
|
|
84
|
+
});
|
|
85
|
+
<% } %>
|
|
89
86
|
|
|
90
87
|
const objectEvents = inject(NgtObjectEvents, { host: true });
|
|
91
88
|
effect(() => {
|
|
@@ -93,6 +90,6 @@ export class <%= className %> {
|
|
|
93
90
|
if (!model) return;
|
|
94
91
|
|
|
95
92
|
objectEvents.ngtObjectEvents.set(model);
|
|
96
|
-
}
|
|
93
|
+
});
|
|
97
94
|
}
|
|
98
95
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.gltfGenerator = gltfGenerator;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
5
|
const node_path_1 = require("node:path");
|
|
5
6
|
const generate_ngt_1 = require("./utils/generate-ngt");
|
|
6
7
|
async function gltfGenerator(tree, options) {
|
|
@@ -14,14 +15,77 @@ async function gltfGenerator(tree, options) {
|
|
|
14
15
|
shadows: options.shadows,
|
|
15
16
|
instance: options.instance,
|
|
16
17
|
instanceall: options.instanceAll,
|
|
17
|
-
keepgroups:
|
|
18
|
-
keepnames:
|
|
18
|
+
keepgroups: options.keepGroups,
|
|
19
|
+
keepnames: options.keepNames,
|
|
19
20
|
precision: options.precision,
|
|
20
21
|
}, allPruneStrategies);
|
|
21
22
|
const generateNGT = new generate_ngt_1.GenerateNGT(analyzed, options);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const scene = await generateNGT.generate();
|
|
24
|
+
const args = generateNGT.args;
|
|
25
|
+
const perspective = generateNGT.ngtTypes.has('PerspectiveCamera');
|
|
26
|
+
const orthographic = generateNGT.ngtTypes.has('OrthographicCamera');
|
|
27
|
+
const { className, fileName } = (0, devkit_1.names)(options.className);
|
|
28
|
+
const gltfExtras = analyzed.gltf.parser.json.asset && analyzed.gltf.parser.json.asset.extras;
|
|
29
|
+
const extras = gltfExtras
|
|
30
|
+
? Object.keys(gltfExtras)
|
|
31
|
+
.map((key) => `${key.charAt(0).toUpperCase() + key.slice(1)}: ${gltfExtras[key]}`)
|
|
32
|
+
.join('\n')
|
|
33
|
+
: '';
|
|
34
|
+
const ngtTypesArr = Array.from(generateNGT.ngtTypes).filter((t) =>
|
|
35
|
+
// group always is the top-level object
|
|
36
|
+
t !== 'Group' &&
|
|
37
|
+
// we render ngts-perspective-camera instead of ngt-perspective-camera
|
|
38
|
+
t !== 'PerspectiveCamera' &&
|
|
39
|
+
// we render ngts-orthographic-camera instead of ngt-orthographic-camera
|
|
40
|
+
t !== 'OrthographicCamera' &&
|
|
41
|
+
// we don't render ngt-bone
|
|
42
|
+
t !== 'Bone' &&
|
|
43
|
+
// we don't render ngt-object3D
|
|
44
|
+
t !== 'Object3D');
|
|
45
|
+
const threeImports = ngtTypesArr.length ? `, ${ngtTypesArr.join(',')}` : '';
|
|
46
|
+
const gltfAnimationTypeName = className + 'AnimationClips';
|
|
47
|
+
const gltfAnimationApiTypeName = className + 'AnimationApi';
|
|
48
|
+
const gltfName = className + 'GLTF';
|
|
49
|
+
const gltfResultTypeName = gltfName + 'GLTFResult';
|
|
50
|
+
const angularImports = [];
|
|
51
|
+
if (args) {
|
|
52
|
+
angularImports.push('NgtArgs');
|
|
53
|
+
}
|
|
54
|
+
if (perspective) {
|
|
55
|
+
angularImports.push('NgtsPerspectiveCamera');
|
|
56
|
+
}
|
|
57
|
+
if (perspective) {
|
|
58
|
+
angularImports.push('NgtsOrthographicCamera');
|
|
59
|
+
}
|
|
60
|
+
const gltfOptions = options.draco ? `{ useDraco: true }` : '';
|
|
61
|
+
const meshes = analyzed.getMeshes();
|
|
62
|
+
const bones = analyzed.getBones();
|
|
63
|
+
const materials = analyzed.getMaterials();
|
|
64
|
+
(0, devkit_1.generateFiles)(tree, (0, node_path_1.join)(__dirname, 'files'), (0, node_path_1.dirname)(options.output), {
|
|
65
|
+
tmpl: '',
|
|
66
|
+
scene,
|
|
67
|
+
fileName,
|
|
68
|
+
className,
|
|
69
|
+
selector: `${options.selectorPrefix}-${fileName}`,
|
|
70
|
+
animations: analyzed.gltf.animations || [],
|
|
71
|
+
extras,
|
|
72
|
+
threeImports,
|
|
73
|
+
args,
|
|
74
|
+
perspective,
|
|
75
|
+
orthographic,
|
|
76
|
+
useImportAttribute: !modelPath.startsWith('http'),
|
|
77
|
+
preload: true,
|
|
78
|
+
gltfName,
|
|
79
|
+
gltfAnimationTypeName,
|
|
80
|
+
gltfAnimationApiTypeName,
|
|
81
|
+
gltfResultTypeName,
|
|
82
|
+
url: modelPath,
|
|
83
|
+
gltfOptions,
|
|
84
|
+
meshes,
|
|
85
|
+
bones,
|
|
86
|
+
materials,
|
|
87
|
+
});
|
|
88
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
25
89
|
}
|
|
26
90
|
exports.default = gltfGenerator;
|
|
27
91
|
//# sourceMappingURL=gltf.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf.js","sourceRoot":"","sources":["../../../../../../libs/plugin/src/generators/gltf/gltf.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"gltf.js","sourceRoot":"","sources":["../../../../../../libs/plugin/src/generators/gltf/gltf.ts"],"names":[],"mappings":";;AA8BA,sCAuGC;AArID,uCAAqE;AACrE,yCAA0C;AAC1C,uDAAmD;AA4B5C,KAAK,UAAU,aAAa,CAAC,IAAU,EAAE,OAA4B;IAC3E,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,EAAE,kBAAkB,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAE9G,MAAM,SAAS,GAAG,IAAA,gBAAI,EAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAErD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,CAAC;IAEvC,MAAM,QAAQ,GAAG,IAAI,YAAY,CAChC,IAAI,EACJ;QACC,GAAG,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QACvD,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU;Q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QACR,KAAK;QACL,QAAQ;QACR,SAAS;QACT,QAAQ,EAAE,GAAG,OAAO,CAAC,cAAc,IAAI,QAAQ,EAAE;QACjD,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE;QAC1C,MAAM;QACN,YAAY;QACZ,IAAI;QACJ,WAAW;QACX,YAAY;QACZ,kBAAkB,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC;QACjD,OAAO,EAAE,IAAI;QACb,QAAQ;QACR,qBAAqB;QACrB,wBAAwB;QACxB,kBAAkB;QAClB,GAAG,EAAE,SAAS;QACd,WAAW;QACX,MAAM;QACN,KAAK;QACL,SAAS;KACT,CAAC,CAAC;IAEH,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,kBAAe,aAAa,CAAC"}
|
|
@@ -105,6 +105,18 @@
|
|
|
105
105
|
"alias": "a",
|
|
106
106
|
"default": false
|
|
107
107
|
},
|
|
108
|
+
"keepNames": {
|
|
109
|
+
"type": "boolean",
|
|
110
|
+
"description": "Keep names of objects",
|
|
111
|
+
"alias": "n",
|
|
112
|
+
"default": false
|
|
113
|
+
},
|
|
114
|
+
"keepGroups": {
|
|
115
|
+
"type": "boolean",
|
|
116
|
+
"description": "Keep groups",
|
|
117
|
+
"alias": "g",
|
|
118
|
+
"default": false
|
|
119
|
+
},
|
|
108
120
|
"format": {
|
|
109
121
|
"type": "string",
|
|
110
122
|
"description": "Texture format jpeg | png | webp | avif (default: \"webp\")",
|