@holoscript/core 6.0.4 → 7.0.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.
- package/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/compiler/index.d.ts +82 -0
- package/dist/constants.d.ts +3 -2
- package/dist/coordinators/index.d.ts +189 -0
- package/dist/index.d.ts +501 -19
- package/dist/paper-0c-spike/index.d.ts +29 -0
- package/dist/reconstruction/index.d.ts +78 -0
- package/dist/tools/index.d.ts +22 -1
- package/dist/traitDocs/traitDocs.d.ts +69 -0
- package/dist/traits/index.d.ts +61 -0
- package/package.json +105 -57
- package/dist/GLTFPipeline-DEN36VNK.js +0 -12
- package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
- package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
- package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
- package/dist/USDZExporter-NTMBNTDB.js +0 -707
- package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
- package/dist/chunk-27LWW5FU.cjs +0 -410
- package/dist/chunk-2CWOLHTE.js +0 -69
- package/dist/chunk-33LSUQDD.cjs +0 -835
- package/dist/chunk-3FJCK5XA.js +0 -2232
- package/dist/chunk-3FXV5S25.cjs +0 -633
- package/dist/chunk-3FYZOR7S.cjs +0 -69
- package/dist/chunk-3SAK5KFL.cjs +0 -83
- package/dist/chunk-4XSNJCLC.cjs +0 -1859
- package/dist/chunk-54FHG2MX.js +0 -655
- package/dist/chunk-56IF4NTA.js +0 -56
- package/dist/chunk-5BGSECRJ.cjs +0 -2237
- package/dist/chunk-5GLCTO44.js +0 -161
- package/dist/chunk-5O6TQC6M.cjs +0 -1871
- package/dist/chunk-5OEOHAAW.cjs +0 -682
- package/dist/chunk-5TOFIR6L.js +0 -407
- package/dist/chunk-5WUNN6ZN.cjs +0 -428
- package/dist/chunk-6TZPZCOJ.cjs +0 -1404
- package/dist/chunk-6UEHYZ7V.cjs +0 -773
- package/dist/chunk-6XSERL6L.js +0 -5678
- package/dist/chunk-72EQECGT.cjs +0 -908
- package/dist/chunk-7AGYRWKW.cjs +0 -507
- package/dist/chunk-7LCYLPW2.cjs +0 -663
- package/dist/chunk-A7PIMZGU.js +0 -263
- package/dist/chunk-ATSKSYVE.cjs +0 -51683
- package/dist/chunk-B5TCIAPQ.cjs +0 -117
- package/dist/chunk-BF2235SI.cjs +0 -5714
- package/dist/chunk-BKIGPPVM.js +0 -629
- package/dist/chunk-BND3ST2K.cjs +0 -662
- package/dist/chunk-BU7VWW2K.js +0 -2522
- package/dist/chunk-BWFJEM5A.js +0 -5419
- package/dist/chunk-CAUCGUEA.cjs +0 -130
- package/dist/chunk-CBJSLA2E.cjs +0 -5423
- package/dist/chunk-CDPGV4DN.js +0 -114
- package/dist/chunk-CLYEIWA5.cjs +0 -408
- package/dist/chunk-CS2EMTGF.js +0 -1966
- package/dist/chunk-DMG7C4H2.js +0 -975
- package/dist/chunk-DXJQDCFL.js +0 -468
- package/dist/chunk-E3FWRT3Z.js +0 -608
- package/dist/chunk-E3UALNFA.js +0 -421
- package/dist/chunk-EONILVMF.js +0 -762
- package/dist/chunk-EQV4R3EV.cjs +0 -769
- package/dist/chunk-F3HH56EB.cjs +0 -5538
- package/dist/chunk-F4IULT7N.js +0 -1488
- package/dist/chunk-FF3Q7ADR.js +0 -380
- package/dist/chunk-FFKU7BTK.cjs +0 -1046
- package/dist/chunk-FHQVYCH2.js +0 -70
- package/dist/chunk-FSF7EQVA.cjs +0 -1974
- package/dist/chunk-G4VZTCIB.js +0 -659
- package/dist/chunk-G7CT3EMP.cjs +0 -1002
- package/dist/chunk-GGHSW2NN.js +0 -51334
- package/dist/chunk-GVUR45UF.cjs +0 -777
- package/dist/chunk-H5Z7NASB.js +0 -9662
- package/dist/chunk-HE7ULERA.cjs +0 -697
- package/dist/chunk-HJJLD366.js +0 -1169
- package/dist/chunk-HPS76H7Q.js +0 -309
- package/dist/chunk-HQUEA5R6.cjs +0 -424
- package/dist/chunk-HYNTS5CP.js +0 -422
- package/dist/chunk-I6XZ5DZF.cjs +0 -488
- package/dist/chunk-IBDG74G2.cjs +0 -1219
- package/dist/chunk-IFNQFCTM.js +0 -3098
- package/dist/chunk-IHOUYQIA.js +0 -406
- package/dist/chunk-ILRBGFVD.cjs +0 -72
- package/dist/chunk-IWI6J7FX.js +0 -421
- package/dist/chunk-K3JDKWGI.cjs +0 -270
- package/dist/chunk-K6EKD26I.js +0 -630
- package/dist/chunk-KCQ5NDYC.cjs +0 -3172
- package/dist/chunk-KED34ILP.js +0 -832
- package/dist/chunk-KSGXLT74.cjs +0 -457
- package/dist/chunk-L4G4RLXX.js +0 -767
- package/dist/chunk-LDP5OK6G.js +0 -1216
- package/dist/chunk-LGGRPKTV.cjs +0 -735
- package/dist/chunk-LK5IAVH6.cjs +0 -1173
- package/dist/chunk-LSW7P7ML.js +0 -3675
- package/dist/chunk-LXJ4667L.cjs +0 -3874
- package/dist/chunk-LZ266PCM.cjs +0 -4499
- package/dist/chunk-MD6KDHVE.cjs +0 -237
- package/dist/chunk-MEASWI2Y.js +0 -126
- package/dist/chunk-MPXBVFHQ.js +0 -768
- package/dist/chunk-N5FTS757.cjs +0 -415
- package/dist/chunk-NCUKG4SK.cjs +0 -3075
- package/dist/chunk-NDQNIJEH.js +0 -1715
- package/dist/chunk-NOZZ46QU.js +0 -168
- package/dist/chunk-OFKWH2IP.js +0 -449
- package/dist/chunk-PHENW4MQ.js +0 -65
- package/dist/chunk-PMGODDJA.cjs +0 -319
- package/dist/chunk-Q4QX3AET.cjs +0 -1505
- package/dist/chunk-Q56TT7IL.js +0 -483
- package/dist/chunk-Q5JT3YML.cjs +0 -129
- package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
- package/dist/chunk-QGKNANZ3.js +0 -3071
- package/dist/chunk-QLEAOI3Q.cjs +0 -424
- package/dist/chunk-R7MA7QWV.js +0 -732
- package/dist/chunk-RVYPEYPX.js +0 -678
- package/dist/chunk-S2N5TNMA.js +0 -1855
- package/dist/chunk-S565K7NK.js +0 -752
- package/dist/chunk-SDAMZIRE.js +0 -765
- package/dist/chunk-T36DDXSF.js +0 -4250
- package/dist/chunk-T4NKMBDL.js +0 -5474
- package/dist/chunk-T7LEXZUZ.cjs +0 -2526
- package/dist/chunk-TEWCN33Y.js +0 -694
- package/dist/chunk-TQSZUOW5.cjs +0 -793
- package/dist/chunk-TSH3MSQU.cjs +0 -129
- package/dist/chunk-UERJ3YJV.js +0 -504
- package/dist/chunk-UPJBDCVF.js +0 -1395
- package/dist/chunk-V3NN3HPP.js +0 -4462
- package/dist/chunk-VJ3L7CHT.cjs +0 -169
- package/dist/chunk-WB4Z63GG.js +0 -229
- package/dist/chunk-WDW67DZB.cjs +0 -9728
- package/dist/chunk-WGMEAYBG.js +0 -126
- package/dist/chunk-X4ZF6CNE.cjs +0 -473
- package/dist/chunk-X6SEAXAX.cjs +0 -3681
- package/dist/chunk-XCWFGZAA.js +0 -1043
- package/dist/chunk-XD6IYDUX.js +0 -903
- package/dist/chunk-XG23EUQX.cjs +0 -1717
- package/dist/chunk-XRKWN5PL.cjs +0 -173
- package/dist/chunk-XUILI4KB.cjs +0 -430
- package/dist/chunk-XUTX5CBW.js +0 -126
- package/dist/chunk-XWPNTWDN.cjs +0 -755
- package/dist/chunk-XXINBTZK.cjs +0 -633
- package/dist/chunk-YCXFCXDS.js +0 -1868
- package/dist/chunk-YQK5JNFK.js +0 -3725
- package/dist/chunk-YYXH45E2.js +0 -426
- package/dist/chunk-Z34RLXRA.cjs +0 -612
- package/dist/chunk-ZP4D3CSX.cjs +0 -72
- package/dist/cli/holoscript-runner.cjs +0 -2259
- package/dist/cli/holoscript-runner.js +0 -2234
- package/dist/codebase/index.cjs +0 -336
- package/dist/codebase/index.js +0 -331
- package/dist/compiler/agent-inference.cjs +0 -28
- package/dist/compiler/agent-inference.js +0 -5
- package/dist/compiler/android-xr.cjs +0 -19
- package/dist/compiler/android-xr.js +0 -9
- package/dist/compiler/android.cjs +0 -20
- package/dist/compiler/android.js +0 -10
- package/dist/compiler/ar.cjs +0 -20
- package/dist/compiler/ar.js +0 -8
- package/dist/compiler/babylon.cjs +0 -17
- package/dist/compiler/babylon.js +0 -11
- package/dist/compiler/coco.cjs +0 -27
- package/dist/compiler/coco.js +0 -4
- package/dist/compiler/domain-block-utils.cjs +0 -602
- package/dist/compiler/domain-block-utils.js +0 -8
- package/dist/compiler/dtdl.cjs +0 -24
- package/dist/compiler/dtdl.js +0 -8
- package/dist/compiler/gltf-pipeline.cjs +0 -39
- package/dist/compiler/gltf-pipeline.js +0 -4
- package/dist/compiler/godot.cjs +0 -15
- package/dist/compiler/godot.js +0 -9
- package/dist/compiler/incremental.cjs +0 -29
- package/dist/compiler/incremental.js +0 -4
- package/dist/compiler/index.cjs +0 -2578
- package/dist/compiler/index.js +0 -2383
- package/dist/compiler/ios.cjs +0 -20
- package/dist/compiler/ios.js +0 -10
- package/dist/compiler/multi-layer.cjs +0 -20
- package/dist/compiler/multi-layer.js +0 -11
- package/dist/compiler/nodetoy.cjs +0 -23
- package/dist/compiler/nodetoy.js +0 -4
- package/dist/compiler/openxr.cjs +0 -15
- package/dist/compiler/openxr.js +0 -9
- package/dist/compiler/playcanvas.cjs +0 -16
- package/dist/compiler/playcanvas.js +0 -10
- package/dist/compiler/r3f.cjs +0 -34
- package/dist/compiler/r3f.js +0 -12
- package/dist/compiler/remotion.cjs +0 -23
- package/dist/compiler/remotion.js +0 -4
- package/dist/compiler/reproducibility.cjs +0 -39
- package/dist/compiler/reproducibility.js +0 -4
- package/dist/compiler/sdf.cjs +0 -21
- package/dist/compiler/sdf.js +0 -9
- package/dist/compiler/semantic-scene.cjs +0 -31
- package/dist/compiler/semantic-scene.js +0 -4
- package/dist/compiler/state.cjs +0 -17
- package/dist/compiler/state.js +0 -7
- package/dist/compiler/trait-composition.cjs +0 -26
- package/dist/compiler/trait-composition.js +0 -5
- package/dist/compiler/unity.cjs +0 -15
- package/dist/compiler/unity.js +0 -9
- package/dist/compiler/unreal.cjs +0 -19
- package/dist/compiler/unreal.js +0 -9
- package/dist/compiler/urdf.cjs +0 -45
- package/dist/compiler/urdf.js +0 -9
- package/dist/compiler/usd-physics.cjs +0 -23
- package/dist/compiler/usd-physics.js +0 -6
- package/dist/compiler/visionos.cjs +0 -15
- package/dist/compiler/visionos.js +0 -9
- package/dist/compiler/vrchat.cjs +0 -19
- package/dist/compiler/vrchat.js +0 -9
- package/dist/compiler/vrr.cjs +0 -21
- package/dist/compiler/vrr.js +0 -9
- package/dist/compiler/wasm.cjs +0 -33
- package/dist/compiler/wasm.js +0 -9
- package/dist/compiler/webgpu.cjs +0 -15
- package/dist/compiler/webgpu.js +0 -9
- package/dist/debugger.cjs +0 -21
- package/dist/debugger.js +0 -8
- package/dist/entries/interop.cjs +0 -62
- package/dist/entries/interop.js +0 -5
- package/dist/entries/scripting.cjs +0 -68
- package/dist/entries/scripting.js +0 -11
- package/dist/index.cjs +0 -40921
- package/dist/index.js +0 -37763
- package/dist/math/vec3.cjs +0 -57
- package/dist/math/vec3.js +0 -4
- package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
- package/dist/ml-dsa-WYLJHJO6.js +0 -1178
- package/dist/parser.cjs +0 -27
- package/dist/parser.js +0 -10
- package/dist/playwright-5OSAPTNH.js +0 -98660
- package/dist/playwright-RL6GY4F7.cjs +0 -98673
- package/dist/runtime.cjs +0 -16
- package/dist/runtime.js +0 -7
- package/dist/storage/index.cjs +0 -37
- package/dist/storage/index.js +0 -4
- package/dist/traits/index.cjs +0 -14649
- package/dist/traits/index.js +0 -12243
- package/dist/type-checker.cjs +0 -18
- package/dist/type-checker.js +0 -5
package/dist/chunk-7AGYRWKW.cjs
DELETED
|
@@ -1,507 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkLXJ4667L_cjs = require('./chunk-LXJ4667L.cjs');
|
|
4
|
-
var chunkBF2235SI_cjs = require('./chunk-BF2235SI.cjs');
|
|
5
|
-
var chunk3SAK5KFL_cjs = require('./chunk-3SAK5KFL.cjs');
|
|
6
|
-
var platform = require('@holoscript/platform');
|
|
7
|
-
|
|
8
|
-
// src/compiler/SDFCompiler.ts
|
|
9
|
-
var SDFCompiler_exports = {};
|
|
10
|
-
chunk3SAK5KFL_cjs.__export(SDFCompiler_exports, {
|
|
11
|
-
SDFCompiler: () => exports.SDFCompiler,
|
|
12
|
-
default: () => exports.SDFCompiler_default
|
|
13
|
-
});
|
|
14
|
-
exports.SDFCompiler = void 0; exports.SDFCompiler_default = void 0;
|
|
15
|
-
var init_SDFCompiler = chunk3SAK5KFL_cjs.__esm({
|
|
16
|
-
"src/compiler/SDFCompiler.ts"() {
|
|
17
|
-
chunkBF2235SI_cjs.init_CompilerBase();
|
|
18
|
-
chunkLXJ4667L_cjs.init_DomainBlockCompilerMixin();
|
|
19
|
-
exports.SDFCompiler = class extends chunkBF2235SI_cjs.CompilerBase {
|
|
20
|
-
constructor(options = {}) {
|
|
21
|
-
super();
|
|
22
|
-
this.compilerName = "SDFCompiler";
|
|
23
|
-
this.lines = [];
|
|
24
|
-
this.indentLevel = 0;
|
|
25
|
-
this.options = {
|
|
26
|
-
worldName: options.worldName || "holoscript_world",
|
|
27
|
-
sdfVersion: options.sdfVersion || "1.8",
|
|
28
|
-
includePhysics: options.includePhysics ?? true,
|
|
29
|
-
physicsEngine: options.physicsEngine || "ode",
|
|
30
|
-
realTimeFactor: options.realTimeFactor ?? 1,
|
|
31
|
-
includeScene: options.includeScene ?? true,
|
|
32
|
-
meshPathPrefix: options.meshPathPrefix || "model://"
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
getRequiredCapability() {
|
|
36
|
-
return platform.ANSCapabilityPath.SDF;
|
|
37
|
-
}
|
|
38
|
-
compile(composition, agentToken, outputPath) {
|
|
39
|
-
this.validateCompilerAccess(agentToken, outputPath);
|
|
40
|
-
this.lines = [];
|
|
41
|
-
this.indentLevel = 0;
|
|
42
|
-
this.emit('<?xml version="1.0"?>');
|
|
43
|
-
this.emit(`<!-- Auto-generated by HoloScript SDFCompiler -->`);
|
|
44
|
-
this.emit(
|
|
45
|
-
`<!-- Source: composition "${this.escapeStringValue(composition.name, "TypeScript")}" -->`
|
|
46
|
-
);
|
|
47
|
-
this.emit("");
|
|
48
|
-
this.emit(`<sdf version="${this.options.sdfVersion}">`);
|
|
49
|
-
this.indentLevel++;
|
|
50
|
-
this.emit(`<world name="${this.escapeXml(this.options.worldName)}">`);
|
|
51
|
-
this.indentLevel++;
|
|
52
|
-
if (this.options.includePhysics) {
|
|
53
|
-
this.emitPhysics();
|
|
54
|
-
}
|
|
55
|
-
if (this.options.includeScene) {
|
|
56
|
-
this.emitScene(composition.environment);
|
|
57
|
-
}
|
|
58
|
-
this.emitGroundPlane();
|
|
59
|
-
this.emitSunLight();
|
|
60
|
-
if (composition.lights) {
|
|
61
|
-
for (const light of composition.lights) {
|
|
62
|
-
this.emitLight(light);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (composition.objects) {
|
|
66
|
-
for (const obj of composition.objects) {
|
|
67
|
-
this.emitModel(obj);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (composition.spatialGroups) {
|
|
71
|
-
for (const group of composition.spatialGroups) {
|
|
72
|
-
this.emitSpatialGroup(group);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
this.emitSDFDomainBlocks(composition);
|
|
76
|
-
this.indentLevel--;
|
|
77
|
-
this.emit("</world>");
|
|
78
|
-
this.indentLevel--;
|
|
79
|
-
this.emit("</sdf>");
|
|
80
|
-
return this.lines.join("\n");
|
|
81
|
-
}
|
|
82
|
-
emitSDFDomainBlocks(composition) {
|
|
83
|
-
const domainBlocks = composition.domainBlocks ?? [];
|
|
84
|
-
if (domainBlocks.length === 0) return;
|
|
85
|
-
this.emit("");
|
|
86
|
-
this.emit("<!-- v4.2 Domain Blocks -->");
|
|
87
|
-
const compiled = chunkLXJ4667L_cjs.compileDomainBlocks(
|
|
88
|
-
domainBlocks,
|
|
89
|
-
{
|
|
90
|
-
material: (block) => {
|
|
91
|
-
const mat = chunkLXJ4667L_cjs.compileMaterialBlock(block);
|
|
92
|
-
return chunkLXJ4667L_cjs.materialToSDF(mat);
|
|
93
|
-
},
|
|
94
|
-
physics: (block) => {
|
|
95
|
-
const phys = chunkLXJ4667L_cjs.compilePhysicsBlock(block);
|
|
96
|
-
return chunkLXJ4667L_cjs.physicsToSDF(phys);
|
|
97
|
-
},
|
|
98
|
-
audio: (block) => {
|
|
99
|
-
const audio = chunkLXJ4667L_cjs.compileAudioSourceBlock(block);
|
|
100
|
-
return `<!-- Audio: ${this.escapeStringValue(audio.name, "TypeScript")} (${audio.keyword}) clip="${audio.properties.clip || ""}" -->`;
|
|
101
|
-
},
|
|
102
|
-
weather: (block) => {
|
|
103
|
-
const weather = chunkLXJ4667L_cjs.compileWeatherBlock(block);
|
|
104
|
-
const layers = weather.layers.map((l) => `<!-- ${l.type}: ${JSON.stringify(l.properties)} -->`).join("\n");
|
|
105
|
-
return `<!-- Weather: ${weather.keyword} "${weather.name || ""}" -->
|
|
106
|
-
${layers}`;
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
(block) => `<!-- Domain block: ${block.domain}/${block.keyword} "${this.escapeStringValue(block.name, "TypeScript")}" -->`
|
|
110
|
-
);
|
|
111
|
-
for (const output of compiled) {
|
|
112
|
-
for (const line of output.split("\n")) {
|
|
113
|
-
this.emit(line);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
// ===== Property extraction helpers =====
|
|
118
|
-
getEnvProp(env, key) {
|
|
119
|
-
if (!env) return void 0;
|
|
120
|
-
if (Array.isArray(env.properties)) {
|
|
121
|
-
const prop = env.properties.find((p) => p.key === key);
|
|
122
|
-
return prop?.value;
|
|
123
|
-
} else {
|
|
124
|
-
return env[key];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
getLightProp(light, key, fallback) {
|
|
128
|
-
if (Array.isArray(light.properties)) {
|
|
129
|
-
const prop = light.properties.find((p) => p.key === key);
|
|
130
|
-
return prop?.value ?? fallback;
|
|
131
|
-
} else if (light[key] !== void 0) {
|
|
132
|
-
return light[key];
|
|
133
|
-
}
|
|
134
|
-
return fallback;
|
|
135
|
-
}
|
|
136
|
-
getTraitName(trait) {
|
|
137
|
-
return typeof trait === "string" ? trait : trait.name;
|
|
138
|
-
}
|
|
139
|
-
hasTrait(obj, traitName) {
|
|
140
|
-
return obj.traits?.some((t) => this.getTraitName(t) === traitName) ?? false;
|
|
141
|
-
}
|
|
142
|
-
emitPhysics() {
|
|
143
|
-
this.emit(`<physics name="default_physics" type="${this.options.physicsEngine}">`);
|
|
144
|
-
this.indentLevel++;
|
|
145
|
-
this.emit("<max_step_size>0.001</max_step_size>");
|
|
146
|
-
this.emit(`<real_time_factor>${this.options.realTimeFactor}</real_time_factor>`);
|
|
147
|
-
this.emit("<real_time_update_rate>1000</real_time_update_rate>");
|
|
148
|
-
if (this.options.physicsEngine === "ode") {
|
|
149
|
-
this.emit("<ode>");
|
|
150
|
-
this.indentLevel++;
|
|
151
|
-
this.emit("<solver>");
|
|
152
|
-
this.indentLevel++;
|
|
153
|
-
this.emit("<type>quick</type>");
|
|
154
|
-
this.emit("<iters>50</iters>");
|
|
155
|
-
this.emit("<sor>1.3</sor>");
|
|
156
|
-
this.indentLevel--;
|
|
157
|
-
this.emit("</solver>");
|
|
158
|
-
this.emit("<constraints>");
|
|
159
|
-
this.indentLevel++;
|
|
160
|
-
this.emit("<cfm>0</cfm>");
|
|
161
|
-
this.emit("<erp>0.2</erp>");
|
|
162
|
-
this.indentLevel--;
|
|
163
|
-
this.emit("</constraints>");
|
|
164
|
-
this.indentLevel--;
|
|
165
|
-
this.emit("</ode>");
|
|
166
|
-
}
|
|
167
|
-
this.indentLevel--;
|
|
168
|
-
this.emit("</physics>");
|
|
169
|
-
this.emit("");
|
|
170
|
-
}
|
|
171
|
-
emitScene(environment) {
|
|
172
|
-
this.emit("<scene>");
|
|
173
|
-
this.indentLevel++;
|
|
174
|
-
const ambientLevel = this.getEnvProp(environment, "ambient_light") ?? 0.4;
|
|
175
|
-
this.emit(`<ambient>${ambientLevel} ${ambientLevel} ${ambientLevel} 1</ambient>`);
|
|
176
|
-
const skybox = this.getEnvProp(environment, "skybox");
|
|
177
|
-
if (skybox) {
|
|
178
|
-
const skyColors = {
|
|
179
|
-
sunset: "0.9 0.5 0.3 1",
|
|
180
|
-
night: "0.05 0.05 0.1 1",
|
|
181
|
-
nebula: "0.1 0.05 0.2 1",
|
|
182
|
-
day: "0.3 0.5 0.9 1",
|
|
183
|
-
overcast: "0.5 0.5 0.5 1"
|
|
184
|
-
};
|
|
185
|
-
this.emit(`<background>${skyColors[skybox] || "0.7 0.7 0.7 1"}</background>`);
|
|
186
|
-
} else {
|
|
187
|
-
this.emit("<background>0.7 0.7 0.7 1</background>");
|
|
188
|
-
}
|
|
189
|
-
this.emit("<shadows>true</shadows>");
|
|
190
|
-
this.indentLevel--;
|
|
191
|
-
this.emit("</scene>");
|
|
192
|
-
this.emit("");
|
|
193
|
-
}
|
|
194
|
-
emitGroundPlane() {
|
|
195
|
-
this.emit('<model name="ground_plane">');
|
|
196
|
-
this.indentLevel++;
|
|
197
|
-
this.emit("<static>true</static>");
|
|
198
|
-
this.emit('<link name="link">');
|
|
199
|
-
this.indentLevel++;
|
|
200
|
-
this.emit('<collision name="collision">');
|
|
201
|
-
this.indentLevel++;
|
|
202
|
-
this.emit("<geometry>");
|
|
203
|
-
this.indentLevel++;
|
|
204
|
-
this.emit("<plane>");
|
|
205
|
-
this.indentLevel++;
|
|
206
|
-
this.emit("<normal>0 0 1</normal>");
|
|
207
|
-
this.emit("<size>100 100</size>");
|
|
208
|
-
this.indentLevel--;
|
|
209
|
-
this.emit("</plane>");
|
|
210
|
-
this.indentLevel--;
|
|
211
|
-
this.emit("</geometry>");
|
|
212
|
-
this.indentLevel--;
|
|
213
|
-
this.emit("</collision>");
|
|
214
|
-
this.emit('<visual name="visual">');
|
|
215
|
-
this.indentLevel++;
|
|
216
|
-
this.emit("<geometry>");
|
|
217
|
-
this.indentLevel++;
|
|
218
|
-
this.emit("<plane>");
|
|
219
|
-
this.indentLevel++;
|
|
220
|
-
this.emit("<normal>0 0 1</normal>");
|
|
221
|
-
this.emit("<size>100 100</size>");
|
|
222
|
-
this.indentLevel--;
|
|
223
|
-
this.emit("</plane>");
|
|
224
|
-
this.indentLevel--;
|
|
225
|
-
this.emit("</geometry>");
|
|
226
|
-
this.emit("<material>");
|
|
227
|
-
this.indentLevel++;
|
|
228
|
-
this.emit("<ambient>0.8 0.8 0.8 1</ambient>");
|
|
229
|
-
this.emit("<diffuse>0.8 0.8 0.8 1</diffuse>");
|
|
230
|
-
this.indentLevel--;
|
|
231
|
-
this.emit("</material>");
|
|
232
|
-
this.indentLevel--;
|
|
233
|
-
this.emit("</visual>");
|
|
234
|
-
this.indentLevel--;
|
|
235
|
-
this.emit("</link>");
|
|
236
|
-
this.indentLevel--;
|
|
237
|
-
this.emit("</model>");
|
|
238
|
-
this.emit("");
|
|
239
|
-
}
|
|
240
|
-
emitSunLight() {
|
|
241
|
-
this.emit('<light name="sun" type="directional">');
|
|
242
|
-
this.indentLevel++;
|
|
243
|
-
this.emit("<cast_shadows>true</cast_shadows>");
|
|
244
|
-
this.emit("<pose>0 0 10 0 0 0</pose>");
|
|
245
|
-
this.emit("<diffuse>0.8 0.8 0.8 1</diffuse>");
|
|
246
|
-
this.emit("<specular>0.2 0.2 0.2 1</specular>");
|
|
247
|
-
this.emit("<direction>-0.5 0.1 -0.9</direction>");
|
|
248
|
-
this.indentLevel--;
|
|
249
|
-
this.emit("</light>");
|
|
250
|
-
this.emit("");
|
|
251
|
-
}
|
|
252
|
-
emitLight(light) {
|
|
253
|
-
const name = this.sanitizeName(light.name || "light");
|
|
254
|
-
const lightTypeValue = light.lightType || (typeof light.type === "string" && ["point", "directional", "spot", "hemisphere", "ambient", "area"].includes(
|
|
255
|
-
light.type
|
|
256
|
-
) ? light.type : void 0);
|
|
257
|
-
const type = this.mapLightType(lightTypeValue);
|
|
258
|
-
this.emit(`<light name="${name}" type="${type}">`);
|
|
259
|
-
this.indentLevel++;
|
|
260
|
-
let castShadow = this.getLightProp(light, "cast_shadow", void 0);
|
|
261
|
-
if (castShadow === void 0) {
|
|
262
|
-
castShadow = this.getLightProp(light, "castShadow", true);
|
|
263
|
-
}
|
|
264
|
-
this.emit(`<cast_shadows>${castShadow}</cast_shadows>`);
|
|
265
|
-
const pos = this.getLightProp(light, "position", [0, 0, 5]);
|
|
266
|
-
this.emit(`<pose>${pos[0]} ${pos[1]} ${pos[2]} 0 0 0</pose>`);
|
|
267
|
-
const colorVal = this.getLightProp(light, "color", "#ffffff");
|
|
268
|
-
const color = this.parseColor(typeof colorVal === "string" ? colorVal : "#ffffff");
|
|
269
|
-
const intensity = this.getLightProp(light, "intensity", 1);
|
|
270
|
-
this.emit(
|
|
271
|
-
`<diffuse>${color.r * intensity} ${color.g * intensity} ${color.b * intensity} 1</diffuse>`
|
|
272
|
-
);
|
|
273
|
-
this.emit(`<specular>${color.r * 0.3} ${color.g * 0.3} ${color.b * 0.3} 1</specular>`);
|
|
274
|
-
if (type === "spot") {
|
|
275
|
-
const angle = this.getLightProp(light, "angle", 45);
|
|
276
|
-
this.emit("<spot>");
|
|
277
|
-
this.indentLevel++;
|
|
278
|
-
this.emit(`<inner_angle>${angle * 0.8 * Math.PI / 180}</inner_angle>`);
|
|
279
|
-
this.emit(`<outer_angle>${angle * Math.PI / 180}</outer_angle>`);
|
|
280
|
-
this.emit("<falloff>1</falloff>");
|
|
281
|
-
this.indentLevel--;
|
|
282
|
-
this.emit("</spot>");
|
|
283
|
-
}
|
|
284
|
-
const range = this.getLightProp(light, "range", 0);
|
|
285
|
-
if (range > 0) {
|
|
286
|
-
this.emit("<attenuation>");
|
|
287
|
-
this.indentLevel++;
|
|
288
|
-
this.emit(`<range>${range}</range>`);
|
|
289
|
-
this.emit("<constant>0.5</constant>");
|
|
290
|
-
this.emit("<linear>0.01</linear>");
|
|
291
|
-
this.emit("<quadratic>0.001</quadratic>");
|
|
292
|
-
this.indentLevel--;
|
|
293
|
-
this.emit("</attenuation>");
|
|
294
|
-
}
|
|
295
|
-
this.indentLevel--;
|
|
296
|
-
this.emit("</light>");
|
|
297
|
-
this.emit("");
|
|
298
|
-
}
|
|
299
|
-
emitModel(obj) {
|
|
300
|
-
const name = this.sanitizeName(obj.name);
|
|
301
|
-
const isStatic = !this.hasTrait(obj, "physics") && !this.hasTrait(obj, "rigid");
|
|
302
|
-
this.emit(`<model name="${name}">`);
|
|
303
|
-
this.indentLevel++;
|
|
304
|
-
if (isStatic) {
|
|
305
|
-
this.emit("<static>true</static>");
|
|
306
|
-
}
|
|
307
|
-
const pos = this.extractPosition(obj);
|
|
308
|
-
const rot = this.extractRotation(obj);
|
|
309
|
-
this.emit(`<pose>${pos[0]} ${pos[1]} ${pos[2]} ${rot[0]} ${rot[1]} ${rot[2]}</pose>`);
|
|
310
|
-
this.emit(`<link name="${name}_link">`);
|
|
311
|
-
this.indentLevel++;
|
|
312
|
-
if (!isStatic) {
|
|
313
|
-
const mass = this.extractMass(obj) || 1;
|
|
314
|
-
this.emit("<inertial>");
|
|
315
|
-
this.indentLevel++;
|
|
316
|
-
this.emit(`<mass>${mass}</mass>`);
|
|
317
|
-
this.emit("<inertia>");
|
|
318
|
-
this.indentLevel++;
|
|
319
|
-
this.emit(`<ixx>${mass * 0.1}</ixx><ixy>0</ixy><ixz>0</ixz>`);
|
|
320
|
-
this.emit(`<iyy>${mass * 0.1}</iyy><iyz>0</iyz>`);
|
|
321
|
-
this.emit(`<izz>${mass * 0.1}</izz>`);
|
|
322
|
-
this.indentLevel--;
|
|
323
|
-
this.emit("</inertia>");
|
|
324
|
-
this.indentLevel--;
|
|
325
|
-
this.emit("</inertial>");
|
|
326
|
-
}
|
|
327
|
-
if (this.hasTrait(obj, "collidable") || this.hasTrait(obj, "physics") || this.hasTrait(obj, "rigid")) {
|
|
328
|
-
this.emit('<collision name="collision">');
|
|
329
|
-
this.indentLevel++;
|
|
330
|
-
this.emitGeometry(obj);
|
|
331
|
-
this.indentLevel--;
|
|
332
|
-
this.emit("</collision>");
|
|
333
|
-
}
|
|
334
|
-
this.emit('<visual name="visual">');
|
|
335
|
-
this.indentLevel++;
|
|
336
|
-
this.emitGeometry(obj);
|
|
337
|
-
this.emitMaterial(obj);
|
|
338
|
-
this.indentLevel--;
|
|
339
|
-
this.emit("</visual>");
|
|
340
|
-
this.indentLevel--;
|
|
341
|
-
this.emit("</link>");
|
|
342
|
-
this.indentLevel--;
|
|
343
|
-
this.emit("</model>");
|
|
344
|
-
this.emit("");
|
|
345
|
-
}
|
|
346
|
-
emitSpatialGroup(group) {
|
|
347
|
-
this.emit(
|
|
348
|
-
`<!-- Spatial Group: ${this.escapeStringValue(group.name, "TypeScript")} -->`
|
|
349
|
-
);
|
|
350
|
-
if (group.objects) {
|
|
351
|
-
for (const obj of group.objects) {
|
|
352
|
-
this.emitModel(obj);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
emitGeometry(obj) {
|
|
357
|
-
const geometryProp = obj.properties.find((p) => p.key === "geometry");
|
|
358
|
-
const geometryValue = geometryProp ? this.getStringValue(geometryProp.value) : "box";
|
|
359
|
-
const scale = this.extractScale(obj);
|
|
360
|
-
this.emit("<geometry>");
|
|
361
|
-
this.indentLevel++;
|
|
362
|
-
switch (geometryValue) {
|
|
363
|
-
case "cube":
|
|
364
|
-
case "box":
|
|
365
|
-
this.emit(`<box><size>${scale} ${scale} ${scale}</size></box>`);
|
|
366
|
-
break;
|
|
367
|
-
case "sphere":
|
|
368
|
-
this.emit(`<sphere><radius>${scale / 2}</radius></sphere>`);
|
|
369
|
-
break;
|
|
370
|
-
case "cylinder":
|
|
371
|
-
this.emit(`<cylinder><radius>${scale / 2}</radius><length>${scale}</length></cylinder>`);
|
|
372
|
-
break;
|
|
373
|
-
case "plane":
|
|
374
|
-
this.emit(`<plane><normal>0 0 1</normal><size>${scale} ${scale}</size></plane>`);
|
|
375
|
-
break;
|
|
376
|
-
case "capsule":
|
|
377
|
-
this.emit(`<capsule><radius>${scale / 3}</radius><length>${scale}</length></capsule>`);
|
|
378
|
-
break;
|
|
379
|
-
default:
|
|
380
|
-
if (geometryValue.includes(".")) {
|
|
381
|
-
this.emit(`<mesh><uri>${this.options.meshPathPrefix}${geometryValue}</uri></mesh>`);
|
|
382
|
-
} else {
|
|
383
|
-
this.emit(`<box><size>${scale} ${scale} ${scale}</size></box>`);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
this.indentLevel--;
|
|
387
|
-
this.emit("</geometry>");
|
|
388
|
-
}
|
|
389
|
-
emitMaterial(obj) {
|
|
390
|
-
const color = this.extractColor(obj);
|
|
391
|
-
this.emit("<material>");
|
|
392
|
-
this.indentLevel++;
|
|
393
|
-
if (color) {
|
|
394
|
-
const rgb = this.parseColor(color);
|
|
395
|
-
this.emit(`<ambient>${rgb.r} ${rgb.g} ${rgb.b} 1</ambient>`);
|
|
396
|
-
this.emit(`<diffuse>${rgb.r} ${rgb.g} ${rgb.b} 1</diffuse>`);
|
|
397
|
-
this.emit(`<specular>0.1 0.1 0.1 1</specular>`);
|
|
398
|
-
if (this.hasTrait(obj, "glowing") || this.hasTrait(obj, "emissive")) {
|
|
399
|
-
this.emit(`<emissive>${rgb.r * 0.5} ${rgb.g * 0.5} ${rgb.b * 0.5} 1</emissive>`);
|
|
400
|
-
}
|
|
401
|
-
} else {
|
|
402
|
-
this.emit("<ambient>0.7 0.7 0.7 1</ambient>");
|
|
403
|
-
this.emit("<diffuse>0.7 0.7 0.7 1</diffuse>");
|
|
404
|
-
}
|
|
405
|
-
this.indentLevel--;
|
|
406
|
-
this.emit("</material>");
|
|
407
|
-
}
|
|
408
|
-
extractPosition(obj) {
|
|
409
|
-
const posProp = obj.properties.find((p) => p.key === "position");
|
|
410
|
-
if (posProp && Array.isArray(posProp.value)) {
|
|
411
|
-
return [
|
|
412
|
-
Number(posProp.value[0]) || 0,
|
|
413
|
-
Number(posProp.value[1]) || 0,
|
|
414
|
-
Number(posProp.value[2]) || 0
|
|
415
|
-
];
|
|
416
|
-
}
|
|
417
|
-
return [0, 0, 0];
|
|
418
|
-
}
|
|
419
|
-
extractRotation(obj) {
|
|
420
|
-
const rotProp = obj.properties.find((p) => p.key === "rotation");
|
|
421
|
-
if (rotProp && Array.isArray(rotProp.value)) {
|
|
422
|
-
return [
|
|
423
|
-
(Number(rotProp.value[0]) || 0) * Math.PI / 180,
|
|
424
|
-
(Number(rotProp.value[1]) || 0) * Math.PI / 180,
|
|
425
|
-
(Number(rotProp.value[2]) || 0) * Math.PI / 180
|
|
426
|
-
];
|
|
427
|
-
}
|
|
428
|
-
return [0, 0, 0];
|
|
429
|
-
}
|
|
430
|
-
extractScale(obj) {
|
|
431
|
-
const scaleProp = obj.properties.find((p) => p.key === "scale");
|
|
432
|
-
if (scaleProp) {
|
|
433
|
-
if (typeof scaleProp.value === "number") return scaleProp.value;
|
|
434
|
-
if (Array.isArray(scaleProp.value)) return Number(scaleProp.value[0]) || 1;
|
|
435
|
-
}
|
|
436
|
-
return 1;
|
|
437
|
-
}
|
|
438
|
-
extractColor(obj) {
|
|
439
|
-
const colorProp = obj.properties.find((p) => p.key === "color");
|
|
440
|
-
return colorProp ? this.getStringValue(colorProp.value) : void 0;
|
|
441
|
-
}
|
|
442
|
-
extractMass(obj) {
|
|
443
|
-
const physicsProp = obj.properties.find((p) => p.key === "physics");
|
|
444
|
-
if (physicsProp && typeof physicsProp.value === "object" && !Array.isArray(physicsProp.value)) {
|
|
445
|
-
const massEntry = physicsProp.value.mass;
|
|
446
|
-
if (typeof massEntry === "number") return massEntry;
|
|
447
|
-
}
|
|
448
|
-
return void 0;
|
|
449
|
-
}
|
|
450
|
-
mapLightType(type) {
|
|
451
|
-
switch (type) {
|
|
452
|
-
case "point":
|
|
453
|
-
return "point";
|
|
454
|
-
case "directional":
|
|
455
|
-
return "directional";
|
|
456
|
-
case "spot":
|
|
457
|
-
return "spot";
|
|
458
|
-
default:
|
|
459
|
-
return "point";
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
parseColor(color) {
|
|
463
|
-
if (color.startsWith("#")) {
|
|
464
|
-
const hex = color.slice(1);
|
|
465
|
-
return {
|
|
466
|
-
r: parseInt(hex.slice(0, 2), 16) / 255,
|
|
467
|
-
g: parseInt(hex.slice(2, 4), 16) / 255,
|
|
468
|
-
b: parseInt(hex.slice(4, 6), 16) / 255
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
const colors = {
|
|
472
|
-
red: { r: 1, g: 0, b: 0 },
|
|
473
|
-
green: { r: 0, g: 1, b: 0 },
|
|
474
|
-
blue: { r: 0, g: 0, b: 1 },
|
|
475
|
-
white: { r: 1, g: 1, b: 1 },
|
|
476
|
-
black: { r: 0, g: 0, b: 0 },
|
|
477
|
-
yellow: { r: 1, g: 1, b: 0 },
|
|
478
|
-
cyan: { r: 0, g: 1, b: 1 },
|
|
479
|
-
magenta: { r: 1, g: 0, b: 1 }
|
|
480
|
-
};
|
|
481
|
-
return colors[color.toLowerCase()] || { r: 0.7, g: 0.7, b: 0.7 };
|
|
482
|
-
}
|
|
483
|
-
emit(line) {
|
|
484
|
-
const indent = " ".repeat(this.indentLevel);
|
|
485
|
-
this.lines.push(indent + line);
|
|
486
|
-
}
|
|
487
|
-
sanitizeName(name) {
|
|
488
|
-
return name.replace(/[^a-zA-Z0-9_]/g, "_").toLowerCase();
|
|
489
|
-
}
|
|
490
|
-
escapeXml(str) {
|
|
491
|
-
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
492
|
-
}
|
|
493
|
-
getStringValue(value) {
|
|
494
|
-
if (typeof value === "string") return value;
|
|
495
|
-
if (typeof value === "number") return String(value);
|
|
496
|
-
if (typeof value === "boolean") return String(value);
|
|
497
|
-
return "";
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
exports.SDFCompiler_default = exports.SDFCompiler;
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
exports.SDFCompiler_exports = SDFCompiler_exports;
|
|
505
|
-
exports.init_SDFCompiler = init_SDFCompiler;
|
|
506
|
-
//# sourceMappingURL=chunk-7AGYRWKW.cjs.map
|
|
507
|
-
//# sourceMappingURL=chunk-7AGYRWKW.cjs.map
|