@holoscript/core 6.0.3 → 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/README.md +40 -40
- package/dist/codebase/index.d.ts +25 -0
- package/dist/compiler/index.d.ts +82 -0
- package/dist/constants.d.ts +4 -0
- package/dist/coordinators/index.d.ts +189 -0
- package/dist/entries/interop.d.ts +9 -0
- package/dist/entries/scripting.d.ts +7 -0
- package/dist/index.d.ts +520 -19
- package/dist/paper-0c-spike/index.d.ts +29 -0
- package/dist/reconstruction/index.d.ts +78 -0
- package/dist/self-improvement/index.d.ts +0 -48
- package/dist/storage/index.d.ts +24 -0
- package/dist/tools/index.d.ts +33 -0
- package/dist/traitDocs/traitDocs.d.ts +69 -0
- package/dist/traits/index.d.ts +61 -0
- package/package.json +102 -19
- package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
- package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
- package/dist/HoloScriptPlusParser-BZR5DELQ.js +0 -692
- package/dist/HoloScriptPlusParser-SBMYDNXO.cjs +0 -697
- package/dist/USDZExporter-MHEHXZB4.cjs +0 -709
- package/dist/USDZExporter-YA55ZS35.js +0 -707
- package/dist/chunk-26TLYBFD.js +0 -309
- package/dist/chunk-27LWW5FU.cjs +0 -410
- package/dist/chunk-2UX5LRAP.cjs +0 -833
- package/dist/chunk-32TWR3HE.js +0 -70
- package/dist/chunk-3FXV5S25.cjs +0 -633
- package/dist/chunk-3FYZOR7S.cjs +0 -69
- package/dist/chunk-3KEU5QYY.cjs +0 -175
- package/dist/chunk-4FCZDTD5.js +0 -610
- package/dist/chunk-4KJ2R7VP.cjs +0 -507
- package/dist/chunk-4SMUJFHL.js +0 -1213
- package/dist/chunk-54FHG2MX.js +0 -655
- package/dist/chunk-56IF4NTA.js +0 -56
- package/dist/chunk-5GLCTO44.js +0 -161
- package/dist/chunk-5TOFIR6L.js +0 -407
- package/dist/chunk-65RFOWZI.js +0 -765
- package/dist/chunk-6OQBLABR.js +0 -5240
- package/dist/chunk-6WNCRE6F.js +0 -126
- package/dist/chunk-74YCHHTE.js +0 -1872
- package/dist/chunk-7H5UNJZD.cjs +0 -1973
- package/dist/chunk-7KPI4EKH.cjs +0 -701
- package/dist/chunk-7LCYLPW2.cjs +0 -663
- package/dist/chunk-7N3JIJMT.js +0 -1395
- package/dist/chunk-7X2IEJIE.cjs +0 -2526
- package/dist/chunk-A6GO3DPZ.cjs +0 -1002
- package/dist/chunk-AC4BSHFV.js +0 -765
- package/dist/chunk-AIUXRS74.cjs +0 -3681
- package/dist/chunk-ARNKA274.cjs +0 -130
- package/dist/chunk-AW7WAELW.js +0 -975
- package/dist/chunk-BKIGPPVM.js +0 -629
- package/dist/chunk-BO2OKHIY.js +0 -6055
- package/dist/chunk-BU5ZAFMC.js +0 -115
- package/dist/chunk-BY3B7ZYV.cjs +0 -457
- package/dist/chunk-C2QHVHZF.js +0 -4066
- package/dist/chunk-C7BNX4XJ.js +0 -1043
- package/dist/chunk-CLYEIWA5.cjs +0 -408
- package/dist/chunk-CMYAWUX3.js +0 -4455
- package/dist/chunk-CN4NOESF.cjs +0 -416
- package/dist/chunk-CNVM7J3M.js +0 -883
- package/dist/chunk-CO2VM2DK.js +0 -1965
- package/dist/chunk-CQDOF3G7.cjs +0 -1404
- package/dist/chunk-DH5G2JUA.cjs +0 -614
- package/dist/chunk-DIEDKX5B.cjs +0 -660
- package/dist/chunk-DN7UFU63.cjs +0 -172
- package/dist/chunk-DXVCEFZB.js +0 -2027
- package/dist/chunk-EGIZHYJP.cjs +0 -85
- package/dist/chunk-EJA7G2C4.cjs +0 -428
- package/dist/chunk-ELLQPFAF.js +0 -830
- package/dist/chunk-EMO7HAKJ.cjs +0 -1875
- package/dist/chunk-ENV7K6XA.js +0 -282
- package/dist/chunk-EPWRXL6S.js +0 -2522
- package/dist/chunk-EUFLX2PI.js +0 -56956
- package/dist/chunk-F5LVGHNT.js +0 -449
- package/dist/chunk-FEFHPUEM.cjs +0 -6122
- package/dist/chunk-FF3Q7ADR.js +0 -380
- package/dist/chunk-GC3YU46J.js +0 -762
- package/dist/chunk-H6WMMLQK.cjs +0 -4492
- package/dist/chunk-H7XMORZI.js +0 -2731
- package/dist/chunk-HAN4V3PF.cjs +0 -2037
- package/dist/chunk-HBZYCASG.js +0 -4208
- package/dist/chunk-HF4OFY25.cjs +0 -4097
- package/dist/chunk-HHS6FMOU.cjs +0 -3813
- package/dist/chunk-HJJLD366.js +0 -1169
- package/dist/chunk-HKCVM6OK.cjs +0 -2237
- package/dist/chunk-HUFNKFA6.js +0 -698
- package/dist/chunk-I3XGTIHM.cjs +0 -1505
- package/dist/chunk-I6XZ5DZF.cjs +0 -488
- package/dist/chunk-IHOUYQIA.js +0 -406
- package/dist/chunk-ILRBGFVD.cjs +0 -72
- package/dist/chunk-KDB6BUMB.js +0 -3666
- package/dist/chunk-KUJRR4FJ.js +0 -657
- package/dist/chunk-KYM4XRFG.js +0 -421
- package/dist/chunk-L3Z2HIWJ.cjs +0 -793
- package/dist/chunk-LBPEZQAF.js +0 -2232
- package/dist/chunk-LER4WXW5.cjs +0 -286
- package/dist/chunk-LK5IAVH6.cjs +0 -1173
- package/dist/chunk-M6FU6S22.js +0 -2911
- package/dist/chunk-MWEFR6YQ.js +0 -1857
- package/dist/chunk-N5FTS757.cjs +0 -415
- package/dist/chunk-NCUHGRTZ.js +0 -752
- package/dist/chunk-NKRKT6V2.js +0 -69
- package/dist/chunk-NLPSZT4C.js +0 -630
- package/dist/chunk-NRUB55IT.cjs +0 -771
- package/dist/chunk-NTMZSDXM.cjs +0 -633
- package/dist/chunk-ODGMVILH.js +0 -9662
- package/dist/chunk-PBA6NXCT.cjs +0 -1216
- package/dist/chunk-PHENW4MQ.js +0 -65
- package/dist/chunk-PJMOXFPR.cjs +0 -1861
- package/dist/chunk-PLMYCCA4.js +0 -504
- package/dist/chunk-PPULB4GG.cjs +0 -9728
- package/dist/chunk-PQLGZKMC.cjs +0 -755
- package/dist/chunk-Q56TT7IL.js +0 -483
- package/dist/chunk-QHVVVN47.cjs +0 -2033
- package/dist/chunk-QWKUKVRE.js +0 -2026
- package/dist/chunk-RE3OKSYF.cjs +0 -424
- package/dist/chunk-RT7LJRSF.cjs +0 -57378
- package/dist/chunk-SPDELRRV.cjs +0 -319
- package/dist/chunk-SUCBB66F.js +0 -229
- package/dist/chunk-TSWTWZ42.cjs +0 -4214
- package/dist/chunk-UITWA6DV.cjs +0 -2829
- package/dist/chunk-UQW6SLM5.js +0 -172
- package/dist/chunk-V2ILLPHK.cjs +0 -237
- package/dist/chunk-V42NTCFH.js +0 -3645
- package/dist/chunk-VJ3L7CHT.cjs +0 -169
- package/dist/chunk-VJVCD5T5.cjs +0 -769
- package/dist/chunk-VK5AXKO3.js +0 -746
- package/dist/chunk-VSXOIUCF.cjs +0 -473
- package/dist/chunk-VZNKJZTT.cjs +0 -749
- package/dist/chunk-W76ETJTI.js +0 -678
- package/dist/chunk-WFJIDI2N.cjs +0 -424
- package/dist/chunk-WN3YF33G.cjs +0 -118
- package/dist/chunk-WUXIRGZP.cjs +0 -2915
- package/dist/chunk-WYH4GVZ5.js +0 -1488
- package/dist/chunk-X4YVN7H3.cjs +0 -888
- package/dist/chunk-X67XRI2T.js +0 -410
- package/dist/chunk-XDXZM3ZP.cjs +0 -1046
- package/dist/chunk-XH7SE4HH.cjs +0 -72
- package/dist/chunk-XNMEH2BI.js +0 -126
- package/dist/chunk-XSF76QRU.js +0 -468
- package/dist/chunk-XSUZMPVQ.cjs +0 -682
- package/dist/chunk-XUILI4KB.cjs +0 -430
- package/dist/chunk-Y5MUAYTO.js +0 -167
- package/dist/chunk-Y7VK5TH3.cjs +0 -129
- package/dist/chunk-YCMQQQ5U.cjs +0 -5244
- package/dist/chunk-YYXH45E2.js +0 -426
- package/dist/chunk-ZGTGVSTZ.js +0 -422
- package/dist/chunk-ZL6VJ6SN.js +0 -421
- package/dist/cli/holoscript-runner.cjs +0 -2258
- package/dist/cli/holoscript-runner.js +0 -2233
- package/dist/codebase/index.cjs +0 -336
- package/dist/codebase/index.js +0 -331
- package/dist/compiler/agent-inference.cjs +0 -29
- package/dist/compiler/agent-inference.js +0 -6
- package/dist/compiler/android-xr.cjs +0 -20
- package/dist/compiler/android-xr.js +0 -10
- package/dist/compiler/android.cjs +0 -21
- package/dist/compiler/android.js +0 -11
- package/dist/compiler/ar.cjs +0 -21
- package/dist/compiler/ar.js +0 -9
- package/dist/compiler/babylon.cjs +0 -18
- package/dist/compiler/babylon.js +0 -12
- package/dist/compiler/coco.cjs +0 -27
- package/dist/compiler/coco.js +0 -4
- package/dist/compiler/domain-block-utils.cjs +0 -595
- package/dist/compiler/domain-block-utils.js +0 -9
- package/dist/compiler/dtdl.cjs +0 -25
- package/dist/compiler/dtdl.js +0 -9
- package/dist/compiler/gltf-pipeline.cjs +0 -39
- package/dist/compiler/gltf-pipeline.js +0 -4
- package/dist/compiler/godot.cjs +0 -16
- package/dist/compiler/godot.js +0 -10
- package/dist/compiler/incremental.cjs +0 -30
- package/dist/compiler/incremental.js +0 -5
- package/dist/compiler/index.cjs +0 -1522
- package/dist/compiler/index.js +0 -1321
- package/dist/compiler/ios.cjs +0 -21
- package/dist/compiler/ios.js +0 -11
- package/dist/compiler/multi-layer.cjs +0 -27
- package/dist/compiler/multi-layer.js +0 -12
- package/dist/compiler/nodetoy.cjs +0 -23
- package/dist/compiler/nodetoy.js +0 -4
- package/dist/compiler/openxr.cjs +0 -16
- package/dist/compiler/openxr.js +0 -10
- package/dist/compiler/playcanvas.cjs +0 -17
- package/dist/compiler/playcanvas.js +0 -11
- package/dist/compiler/r3f.cjs +0 -35
- package/dist/compiler/r3f.js +0 -13
- 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 -22
- package/dist/compiler/sdf.js +0 -10
- package/dist/compiler/semantic-scene.cjs +0 -31
- package/dist/compiler/semantic-scene.js +0 -4
- package/dist/compiler/state.cjs +0 -18
- package/dist/compiler/state.js +0 -8
- package/dist/compiler/trait-composition.cjs +0 -27
- package/dist/compiler/trait-composition.js +0 -6
- package/dist/compiler/unity.cjs +0 -16
- package/dist/compiler/unity.js +0 -10
- package/dist/compiler/unreal.cjs +0 -20
- package/dist/compiler/unreal.js +0 -10
- package/dist/compiler/urdf.cjs +0 -46
- package/dist/compiler/urdf.js +0 -10
- package/dist/compiler/usd-physics.cjs +0 -24
- package/dist/compiler/usd-physics.js +0 -7
- package/dist/compiler/visionos.cjs +0 -16
- package/dist/compiler/visionos.js +0 -10
- package/dist/compiler/vrchat.cjs +0 -20
- package/dist/compiler/vrchat.js +0 -10
- package/dist/compiler/vrr.cjs +0 -22
- package/dist/compiler/vrr.js +0 -10
- package/dist/compiler/wasm.cjs +0 -34
- package/dist/compiler/wasm.js +0 -10
- package/dist/compiler/webgpu.cjs +0 -16
- package/dist/compiler/webgpu.js +0 -10
- 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 -67
- package/dist/entries/scripting.js +0 -10
- package/dist/index.cjs +0 -61703
- package/dist/index.js +0 -58652
- package/dist/math/vec3.cjs +0 -57
- package/dist/math/vec3.js +0 -4
- package/dist/parser.cjs +0 -26
- package/dist/parser.js +0 -9
- package/dist/playwright-7DTEQCBD.cjs +0 -98673
- package/dist/playwright-BIZXMLD2.js +0 -98660
- package/dist/post-quantum-JTTAAGO3.cjs +0 -6
- package/dist/post-quantum-RVPVDEPI.js +0 -4
- 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 -14331
- package/dist/traits/index.js +0 -12126
- package/dist/type-checker.cjs +0 -18
- package/dist/type-checker.js +0 -5
- package/dist/wot/index.cjs +0 -29
- package/dist/wot/index.js +0 -4
package/dist/chunk-4KJ2R7VP.cjs
DELETED
|
@@ -1,507 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkHHS6FMOU_cjs = require('./chunk-HHS6FMOU.cjs');
|
|
4
|
-
var chunkQHVVVN47_cjs = require('./chunk-QHVVVN47.cjs');
|
|
5
|
-
var chunkEGIZHYJP_cjs = require('./chunk-EGIZHYJP.cjs');
|
|
6
|
-
|
|
7
|
-
// src/compiler/SDFCompiler.ts
|
|
8
|
-
var SDFCompiler_exports = {};
|
|
9
|
-
chunkEGIZHYJP_cjs.__export(SDFCompiler_exports, {
|
|
10
|
-
SDFCompiler: () => exports.SDFCompiler,
|
|
11
|
-
default: () => exports.SDFCompiler_default
|
|
12
|
-
});
|
|
13
|
-
exports.SDFCompiler = void 0; exports.SDFCompiler_default = void 0;
|
|
14
|
-
var init_SDFCompiler = chunkEGIZHYJP_cjs.__esm({
|
|
15
|
-
"src/compiler/SDFCompiler.ts"() {
|
|
16
|
-
chunkQHVVVN47_cjs.init_CompilerBase();
|
|
17
|
-
chunkQHVVVN47_cjs.init_ANSNamespace();
|
|
18
|
-
chunkHHS6FMOU_cjs.init_DomainBlockCompilerMixin();
|
|
19
|
-
exports.SDFCompiler = class extends chunkQHVVVN47_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 chunkQHVVVN47_cjs.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 = chunkHHS6FMOU_cjs.compileDomainBlocks(
|
|
88
|
-
domainBlocks,
|
|
89
|
-
{
|
|
90
|
-
material: (block) => {
|
|
91
|
-
const mat = chunkHHS6FMOU_cjs.compileMaterialBlock(block);
|
|
92
|
-
return chunkHHS6FMOU_cjs.materialToSDF(mat);
|
|
93
|
-
},
|
|
94
|
-
physics: (block) => {
|
|
95
|
-
const phys = chunkHHS6FMOU_cjs.compilePhysicsBlock(block);
|
|
96
|
-
return chunkHHS6FMOU_cjs.physicsToSDF(phys);
|
|
97
|
-
},
|
|
98
|
-
audio: (block) => {
|
|
99
|
-
const audio = chunkHHS6FMOU_cjs.compileAudioSourceBlock(block);
|
|
100
|
-
return `<!-- Audio: ${this.escapeStringValue(audio.name, "TypeScript")} (${audio.keyword}) clip="${audio.properties.clip || ""}" -->`;
|
|
101
|
-
},
|
|
102
|
-
weather: (block) => {
|
|
103
|
-
const weather = chunkHHS6FMOU_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-4KJ2R7VP.cjs.map
|
|
507
|
-
//# sourceMappingURL=chunk-4KJ2R7VP.cjs.map
|