@babylonjs/inspector 8.43.0 → 8.44.0-preview

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.
@@ -0,0 +1,538 @@
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { P as Popover, b as Button, c as TextInputPropertyLine, d as SpinButtonPropertyLine, e as CheckboxPropertyLine, V as Vector3PropertyLine, f as ShellServiceIdentity, g as SceneContextIdentity, u as useObservableState, A as Accordion, h as AccordionSection } from './index-2Bq-qBwV.js';
3
+ import { SettingsRegular, CollectionsAdd20Regular } from '@fluentui/react-icons';
4
+ import '@babylonjs/core/Particles/webgl2ParticleSystem.js';
5
+ import { MeshBuilder } from '@babylonjs/core/Meshes/meshBuilder.js';
6
+ import { useState, useRef } from 'react';
7
+ import { makeStyles, tokens } from '@fluentui/react-components';
8
+ import { FilesInput } from '@babylonjs/core/Misc/filesInput.js';
9
+ import { NodeMaterial } from '@babylonjs/core/Materials/Node/nodeMaterial.js';
10
+ import { PBRMaterial } from '@babylonjs/core/Materials/PBR/pbrMaterial.js';
11
+ import { StandardMaterial } from '@babylonjs/core/Materials/standardMaterial.js';
12
+ import { PointLight } from '@babylonjs/core/Lights/pointLight.js';
13
+ import { DirectionalLight } from '@babylonjs/core/Lights/directionalLight.js';
14
+ import { SpotLight } from '@babylonjs/core/Lights/spotLight.js';
15
+ import { Vector3 } from '@babylonjs/core/Maths/math.vector.js';
16
+ import { ArcRotateCamera } from '@babylonjs/core/Cameras/arcRotateCamera.js';
17
+ import { UniversalCamera } from '@babylonjs/core/Cameras/universalCamera.js';
18
+ import { ParticleSystem } from '@babylonjs/core/Particles/particleSystem.js';
19
+ import { GPUParticleSystem } from '@babylonjs/core/Particles/gpuParticleSystem.js';
20
+ import { NodeParticleSystemSet } from '@babylonjs/core/Particles/Node/nodeParticleSystemSet.js';
21
+ import { Texture } from '@babylonjs/core/Materials/Textures/texture.js';
22
+ import '@babylonjs/core/Maths/math.color.js';
23
+ import '@babylonjs/core/Misc/observable.js';
24
+ import '@fluentui/react-motion-components-preview';
25
+ import '@babylonjs/core/Misc/typeStore.js';
26
+ import 'usehooks-ts';
27
+ import '@babylonjs/core/Misc/asyncLock.js';
28
+ import '@babylonjs/core/Misc/deferred.js';
29
+ import '@babylonjs/core/Misc/logger.js';
30
+ import '@babylonjs/core/Maths/math.scalar.functions.js';
31
+ import '@fluentui-contrib/react-virtualizer';
32
+ import '@babylonjs/addons/msdfText/fontAsset.js';
33
+ import '@babylonjs/addons/msdfText/textRenderer.js';
34
+ import '@babylonjs/core/Debug/physicsViewer.js';
35
+ import '@babylonjs/core/Materials/materialFlags.js';
36
+ import '@babylonjs/core/Meshes/Builders/groundBuilder.js';
37
+ import '@babylonjs/core/Misc/tools.js';
38
+ import '@babylonjs/core/Rendering/utilityLayerRenderer.js';
39
+ import '@babylonjs/materials/grid/gridMaterial.js';
40
+ import '@babylonjs/core/Misc/dataStorage.js';
41
+ import '@babylonjs/core/Instrumentation/engineInstrumentation.js';
42
+ import '@babylonjs/core/Instrumentation/sceneInstrumentation.js';
43
+ import '@babylonjs/core/Engines/AbstractEngine/abstractEngine.timeQuery.js';
44
+ import '@babylonjs/core/Engines/Extensions/engine.query.js';
45
+ import '@babylonjs/core/Engines/WebGPU/Extensions/engine.query.js';
46
+ import '@babylonjs/core/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js';
47
+ import '@babylonjs/core/Misc/PerformanceViewer/performanceViewerSceneExtension.js';
48
+ import '@babylonjs/core/Misc/pressureObserverWrapper.js';
49
+ import '@babylonjs/core/Engines/abstractEngine.js';
50
+ import 'react-dom/client';
51
+ import '@babylonjs/core/FrameGraph/frameGraphUtils.js';
52
+ import '@babylonjs/core/Gizmos/cameraGizmo.js';
53
+ import '@babylonjs/core/Gizmos/lightGizmo.js';
54
+ import '@babylonjs/core/Bones/bone.js';
55
+ import '@babylonjs/core/Cameras/camera.js';
56
+ import '@babylonjs/core/Gizmos/gizmoManager.js';
57
+ import '@babylonjs/core/Lights/light.js';
58
+ import '@babylonjs/core/Meshes/abstractMesh.js';
59
+ import '@babylonjs/core/node.js';
60
+ import '@babylonjs/core/Animations/animationGroup.js';
61
+ import '@babylonjs/core/Animations/animationPropertiesOverride.js';
62
+ import '@babylonjs/addons/atmosphere/atmosphere.js';
63
+ import '@babylonjs/core/Cameras/followCamera.js';
64
+ import '@babylonjs/core/Cameras/freeCamera.js';
65
+ import '@babylonjs/core/Cameras/targetCamera.js';
66
+ import '@babylonjs/core/scene.js';
67
+ import '@babylonjs/core/FrameGraph/frameGraph.js';
68
+ import '@babylonjs/core/Lights/hemisphericLight.js';
69
+ import '@babylonjs/core/Lights/rectAreaLight.js';
70
+ import '@babylonjs/core/Lights/shadowLight.js';
71
+ import '@babylonjs/core/Lights/Shadows/cascadedShadowGenerator.js';
72
+ import '@babylonjs/core/Lights/Shadows/shadowGenerator.js';
73
+ import '@babylonjs/core/Lights/Shadows/shadowGeneratorSceneComponent.js';
74
+ import '@babylonjs/core/Materials/material.js';
75
+ import '@babylonjs/core/Materials/multiMaterial.js';
76
+ import '@babylonjs/core/Materials/PBR/pbrBaseMaterial.js';
77
+ import '@babylonjs/core/Materials/PBR/pbrBaseSimpleMaterial.js';
78
+ import '@babylonjs/core/Materials/PBR/openpbrMaterial.js';
79
+ import '@babylonjs/materials/sky/skyMaterial.js';
80
+ import '@babylonjs/core/Engines/constants.js';
81
+ import '@babylonjs/core/Engines/engine.js';
82
+ import '@babylonjs/core/Misc/fileTools.js';
83
+ import '@babylonjs/core/Materials/Textures/cubeTexture.js';
84
+ import '@babylonjs/core/Meshes/mesh.js';
85
+ import '@babylonjs/core/Debug/skeletonViewer.js';
86
+ import '@babylonjs/core/Meshes/buffer.js';
87
+ import '@babylonjs/core/Meshes/Builders/linesBuilder.js';
88
+ import '@babylonjs/core/Meshes/instancedMesh.js';
89
+ import '@babylonjs/core/Rendering/renderingManager.js';
90
+ import '@babylonjs/core/Rendering/edgesRenderer.js';
91
+ import '@babylonjs/core/Rendering/outlineRenderer.js';
92
+ import '@babylonjs/core/Meshes/GaussianSplatting/gaussianSplattingMesh.js';
93
+ import '@babylonjs/core/Misc/gradients.js';
94
+ import '@babylonjs/core/Materials/Node/Blocks/gradientBlock.js';
95
+ import '@babylonjs/core/Particles/attractor.js';
96
+ import '@babylonjs/core/Meshes/Builders/sphereBuilder.js';
97
+ import '@babylonjs/core/Meshes/transformNode.js';
98
+ import '@babylonjs/core/Physics/v2/IPhysicsEnginePlugin.js';
99
+ import '@babylonjs/core/Physics/v2/physicsEngineComponent.js';
100
+ import '@babylonjs/core/PostProcesses/postProcess.js';
101
+ import '@babylonjs/core/Materials/imageProcessingConfiguration.js';
102
+ import '@babylonjs/core/Bones/skeleton.js';
103
+ import '@babylonjs/core/Sprites/sprite.js';
104
+ import '@babylonjs/core/Sprites/spriteManager.js';
105
+ import '@babylonjs/core/Misc/textureTools.js';
106
+ import '@babylonjs/core/Materials/Textures/baseTexture.js';
107
+ import '@babylonjs/core/Materials/Textures/multiRenderTarget.js';
108
+ import '@babylonjs/core/Materials/Textures/renderTargetTexture.js';
109
+ import '@babylonjs/core/Materials/Textures/thinTexture.js';
110
+ import '@babylonjs/core/Events/keyboardEvents.js';
111
+ import '@babylonjs/core/Events/pointerEvents.js';
112
+ import '@babylonjs/core/Materials/Textures/htmlElementTexture.js';
113
+ import '@babylonjs/core/Materials/shaderMaterial.js';
114
+ import '@babylonjs/core/Meshes/Builders/planeBuilder.js';
115
+ import '@babylonjs/core/Lights/Clustered/clusteredLightContainer.js';
116
+ import '@babylonjs/core/Rendering/boundingBoxRenderer.js';
117
+ import '@babylonjs/core/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.js';
118
+ import '@babylonjs/core/Sprites/spriteSceneComponent.js';
119
+ import '@babylonjs/core/Materials/Textures/dynamicTexture.js';
120
+ import '@babylonjs/core/Engines/engineStore.js';
121
+ import '@babylonjs/core/Misc/uniqueIdGenerator.js';
122
+ import '@babylonjs/core/Debug/debugLayer.js';
123
+ import '@babylonjs/core/Misc/lazy.js';
124
+
125
+ /**
126
+ * Settings popover component
127
+ * @param props
128
+ * @returns
129
+ */
130
+ const SettingsPopover = (props) => {
131
+ return jsxs(Popover, { icon: SettingsRegular, children: [" ", props.children, " "] });
132
+ };
133
+
134
+ const useStyles$4 = makeStyles({
135
+ section: {
136
+ display: "flex",
137
+ flexDirection: "column",
138
+ rowGap: tokens.spacingVerticalM,
139
+ },
140
+ row: { display: "flex", alignItems: "center", gap: "4px" },
141
+ });
142
+ const SetCamera = function (scene) {
143
+ const camera = scene.activeCamera;
144
+ if (camera && camera.radius !== undefined) {
145
+ camera.radius = 5;
146
+ }
147
+ };
148
+ /**
149
+ * @internal
150
+ */
151
+ const MeshesContent = ({ scene }) => {
152
+ const classes = useStyles$4();
153
+ const [sphereParams, setSphereParams] = useState({
154
+ name: "Sphere",
155
+ segments: 32,
156
+ diameter: 1,
157
+ diameterX: 1,
158
+ diameterY: 1,
159
+ diameterZ: 1,
160
+ arc: 1,
161
+ slice: 1,
162
+ uniform: true,
163
+ });
164
+ const handleSphereParamChange = (key, value) => {
165
+ setSphereParams((prev) => ({
166
+ ...prev,
167
+ [key]: value,
168
+ }));
169
+ };
170
+ const [boxParams, setBoxParams] = useState({
171
+ name: "Box",
172
+ size: 1,
173
+ width: 1,
174
+ height: 1,
175
+ depth: 1,
176
+ });
177
+ const handleBoxParamChange = (key, value) => {
178
+ setBoxParams((prev) => ({
179
+ ...prev,
180
+ [key]: value,
181
+ }));
182
+ };
183
+ const [cylinderParams, setCylinderParams] = useState({
184
+ name: "Cylinder",
185
+ height: 2,
186
+ diameterTop: 1,
187
+ diameterBottom: 1,
188
+ diameter: 1,
189
+ tessellation: 32,
190
+ subdivisions: 1,
191
+ arc: 1,
192
+ });
193
+ const handleCylinderParamChange = (key, value) => {
194
+ setCylinderParams((prev) => ({
195
+ ...prev,
196
+ [key]: value,
197
+ }));
198
+ };
199
+ const [coneParams, setConeParams] = useState({
200
+ name: "Cone",
201
+ height: 2,
202
+ diameter: 1,
203
+ diameterTop: 0,
204
+ diameterBottom: 1,
205
+ tessellation: 32,
206
+ subdivisions: 1,
207
+ arc: 1,
208
+ });
209
+ const [coneUp, setConeUp] = useState(true);
210
+ const handleConeParamChange = (key, value) => {
211
+ setConeParams((prev) => ({
212
+ ...prev,
213
+ [key]: value,
214
+ }));
215
+ };
216
+ const [groundParams, setGroundParams] = useState({
217
+ name: "Ground",
218
+ width: 10,
219
+ height: 10,
220
+ subdivisions: 1,
221
+ subdivisionsX: 1,
222
+ subdivisionsY: 1,
223
+ });
224
+ const handleGroundParamChange = (key, value) => {
225
+ setGroundParams((prev) => ({
226
+ ...prev,
227
+ [key]: value,
228
+ }));
229
+ };
230
+ const fileInputRef = useRef(null);
231
+ const [importMeshName, setImportMeshName] = useState("ImportedMesh");
232
+ const handleLocalMeshImport = (event) => {
233
+ const files = event.target.files;
234
+ if (!files || files.length === 0) {
235
+ return;
236
+ }
237
+ const filesArray = Array.from(files);
238
+ if (importMeshName.trim().length > 0 && filesArray.length > 0) {
239
+ const originalFile = filesArray[0];
240
+ const extensionIndex = originalFile.name.lastIndexOf(".");
241
+ const extension = extensionIndex >= 0 ? originalFile.name.substring(extensionIndex) : "";
242
+ const sanitizedName = importMeshName.trim();
243
+ const desiredFileName = sanitizedName.toLowerCase().endsWith(extension.toLowerCase()) ? sanitizedName : `${sanitizedName}${extension}`;
244
+ filesArray[0] = new File([originalFile], desiredFileName, { type: originalFile.type, lastModified: originalFile.lastModified });
245
+ }
246
+ const filesInput = new FilesInput(scene.getEngine(), scene, null, null, null, null, null, null, (_sceneFile, _scene, message) => {
247
+ alert(message ? `Failed to import mesh: ${message}` : "Failed to import mesh.");
248
+ }, true);
249
+ filesInput.displayLoadingUI = false;
250
+ filesInput.loadFiles({ target: { files: filesArray } });
251
+ filesInput.dispose();
252
+ event.target.value = "";
253
+ };
254
+ return (jsxs("div", { className: classes.section, children: [jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: () => {
255
+ MeshBuilder.CreateSphere("Sphere", {}, scene);
256
+ SetCamera(scene);
257
+ }, label: "Sphere" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: sphereParams.name, onChange: (val) => handleSphereParamChange("name", val) }), jsx(SpinButtonPropertyLine, { label: "Segments", value: sphereParams.segments, min: 0, onChange: (val) => handleSphereParamChange("segments", val) }), jsx(SpinButtonPropertyLine, { label: "Diameter", value: sphereParams.diameter, min: 0, step: 0.1, onChange: (val) => handleSphereParamChange("diameter", val), disabled: !sphereParams.uniform }), jsx(CheckboxPropertyLine, { label: "Uniform", value: sphereParams.uniform, onChange: (checked) => handleSphereParamChange("uniform", checked) }), jsx(SpinButtonPropertyLine, { label: "Diameter X", value: sphereParams.diameterX, min: 0, step: 0.1, onChange: (val) => handleSphereParamChange("diameterX", val), disabled: sphereParams.uniform }), jsx(SpinButtonPropertyLine, { label: "Diameter Y", value: sphereParams.diameterY, min: 0, step: 0.1, onChange: (val) => handleSphereParamChange("diameterY", val), disabled: sphereParams.uniform }), jsx(SpinButtonPropertyLine, { label: "Diameter Z", value: sphereParams.diameterZ, min: 0, step: 0.1, onChange: (val) => handleSphereParamChange("diameterZ", val), disabled: sphereParams.uniform }), jsx(SpinButtonPropertyLine, { label: "Arc", value: sphereParams.arc, min: 0, max: 1, step: 0.1, onChange: (val) => handleSphereParamChange("arc", val) }), jsx(SpinButtonPropertyLine, { label: "Slice", value: sphereParams.slice, min: 0, max: 1, step: 0.1, onChange: (val) => handleSphereParamChange("slice", val) }), jsx("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8, marginTop: 16 }, children: jsx(Button, { appearance: "primary", onClick: () => {
258
+ // Create params object based on uniform checkbox
259
+ const createParams = {
260
+ segments: sphereParams.segments,
261
+ arc: sphereParams.arc,
262
+ slice: sphereParams.slice,
263
+ };
264
+ if (sphereParams.uniform) {
265
+ // If uniform is checked, use diameter
266
+ createParams.diameter = sphereParams.diameter;
267
+ }
268
+ else {
269
+ // If uniform is unchecked, use individual diameters
270
+ createParams.diameterX = sphereParams.diameterX;
271
+ createParams.diameterY = sphereParams.diameterY;
272
+ createParams.diameterZ = sphereParams.diameterZ;
273
+ }
274
+ MeshBuilder.CreateSphere(sphereParams.name, createParams, scene);
275
+ SetCamera(scene);
276
+ }, label: "Create" }) })] })] }), jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: () => {
277
+ MeshBuilder.CreateBox("Box", {}, scene);
278
+ SetCamera(scene);
279
+ }, label: "Box" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: boxParams.name, onChange: (val) => handleBoxParamChange("name", val) }), jsx(SpinButtonPropertyLine, { label: "Size", value: boxParams.size, min: 0, step: 0.1, onChange: (val) => handleBoxParamChange("size", val) }), jsx(SpinButtonPropertyLine, { label: "Width", value: boxParams.width, min: 0, step: 0.1, onChange: (val) => handleBoxParamChange("width", val) }), jsx(SpinButtonPropertyLine, { label: "Height", value: boxParams.height, min: 0, step: 0.1, onChange: (val) => handleBoxParamChange("height", val) }), jsx(SpinButtonPropertyLine, { label: "Depth", value: boxParams.depth, min: 0, step: 0.1, onChange: (val) => handleBoxParamChange("depth", val) }), jsx("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8, marginTop: 16 }, children: jsx(Button, { appearance: "primary", onClick: () => {
280
+ MeshBuilder.CreateBox(boxParams.name, boxParams, scene);
281
+ SetCamera(scene);
282
+ }, label: "Create" }) })] })] }), jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: () => {
283
+ MeshBuilder.CreateCylinder("Cylinder", {}, scene);
284
+ SetCamera(scene);
285
+ }, label: "Cylinder" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: cylinderParams.name, onChange: (val) => handleCylinderParamChange("name", val) }), jsx(SpinButtonPropertyLine, { label: "Height", value: cylinderParams.height, min: 0, step: 0.1, onChange: (val) => handleCylinderParamChange("height", val) }), jsx(SpinButtonPropertyLine, { label: "Diameter Top", value: cylinderParams.diameterTop, min: 0, step: 0.1, onChange: (val) => handleCylinderParamChange("diameterTop", val) }), jsx(SpinButtonPropertyLine, { label: "Diameter Bottom", value: cylinderParams.diameterBottom, min: 0, step: 0.1, onChange: (val) => handleCylinderParamChange("diameterBottom", val) }), jsx(SpinButtonPropertyLine, { label: "Diameter", value: cylinderParams.diameter, min: 0, step: 0.1, onChange: (val) => handleCylinderParamChange("diameter", val) }), jsx(SpinButtonPropertyLine, { label: "Tessellation", value: cylinderParams.tessellation, min: 3, onChange: (val) => handleCylinderParamChange("tessellation", val) }), jsx(SpinButtonPropertyLine, { label: "Subdivisions", value: cylinderParams.subdivisions, min: 1, onChange: (val) => handleCylinderParamChange("subdivisions", val) }), jsx(SpinButtonPropertyLine, { label: "Arc", value: cylinderParams.arc, min: 0, max: 1, step: 0.1, onChange: (val) => handleCylinderParamChange("arc", val) }), jsx("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8, marginTop: 16 }, children: jsx(Button, { appearance: "primary", onClick: () => {
286
+ MeshBuilder.CreateCylinder(cylinderParams.name, cylinderParams, scene);
287
+ SetCamera(scene);
288
+ }, label: "Create" }) })] })] }), jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: () => {
289
+ MeshBuilder.CreateCylinder("Cone", { diameterTop: 0 }, scene);
290
+ SetCamera(scene);
291
+ }, label: "Cone" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: coneParams.name, onChange: (val) => handleConeParamChange("name", val) }), jsx(SpinButtonPropertyLine, { label: "Height", value: coneParams.height, min: 0, step: 0.1, onChange: (val) => handleConeParamChange("height", val) }), jsx(SpinButtonPropertyLine, { label: "Diameter", value: coneParams.diameter, min: 0, step: 0.1, onChange: (val) => handleConeParamChange("diameter", val) }), jsx(SpinButtonPropertyLine, { label: "Tessellation", value: coneParams.tessellation, min: 3, onChange: (val) => handleConeParamChange("tessellation", val) }), jsx(SpinButtonPropertyLine, { label: "Subdivisions", value: coneParams.subdivisions, min: 1, onChange: (val) => handleConeParamChange("subdivisions", val) }), jsx(SpinButtonPropertyLine, { label: "Arc", value: coneParams.arc, min: 0, max: 1, step: 0.1, onChange: (val) => handleConeParamChange("arc", val) }), jsx(CheckboxPropertyLine, { label: "Up", value: coneUp, onChange: (val) => setConeUp(val) }), jsx("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8, marginTop: 16 }, children: jsx(Button, { appearance: "primary", onClick: () => {
292
+ const coneParamsToUse = {
293
+ ...coneParams,
294
+ diameterTop: coneUp ? 0 : coneParams.diameterTop,
295
+ diameterBottom: coneUp ? coneParams.diameterBottom : 0,
296
+ };
297
+ MeshBuilder.CreateCylinder(coneParams.name, coneParamsToUse, scene);
298
+ SetCamera(scene);
299
+ }, label: "Create" }) })] })] }), jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: () => {
300
+ MeshBuilder.CreateGround("Ground", {}, scene);
301
+ SetCamera(scene);
302
+ }, label: "Ground" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: groundParams.name, onChange: (val) => handleGroundParamChange("name", val) }), jsx(SpinButtonPropertyLine, { label: "Width", value: groundParams.width, min: 0, step: 0.1, onChange: (val) => handleGroundParamChange("width", val) }), jsx(SpinButtonPropertyLine, { label: "Height", value: groundParams.height, min: 0, step: 0.1, onChange: (val) => handleGroundParamChange("height", val) }), jsx(SpinButtonPropertyLine, { label: "Subdivisions", value: groundParams.subdivisions, min: 1, onChange: (val) => handleGroundParamChange("subdivisions", val) }), jsx(SpinButtonPropertyLine, { label: "Subdivisions X", value: groundParams.subdivisionsX, min: 1, onChange: (val) => handleGroundParamChange("subdivisionsX", val) }), jsx(SpinButtonPropertyLine, { label: "Subdivisions Y", value: groundParams.subdivisionsY, min: 1, onChange: (val) => handleGroundParamChange("subdivisionsY", val) }), jsx("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8, marginTop: 16 }, children: jsx(Button, { appearance: "primary", onClick: () => {
303
+ MeshBuilder.CreateGround(groundParams.name, groundParams, scene);
304
+ SetCamera(scene);
305
+ }, label: "Create" }) })] })] }), jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: () => {
306
+ fileInputRef.current?.click();
307
+ }, label: "Import Mesh" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: importMeshName, onChange: (val) => setImportMeshName(val) }), jsx("div", { style: { display: "flex", justifyContent: "flex-end", gap: 8 }, children: jsx(Button, { appearance: "primary", onClick: () => {
308
+ fileInputRef.current?.click();
309
+ }, label: "Import" }) })] }), jsx("input", { ref: fileInputRef, type: "file", accept: ".babylon,.glb,.gltf,.obj,.stl,.ply,.mesh,.babylonmeshdata", multiple: true, style: { display: "none" }, onChange: handleLocalMeshImport })] })] }));
310
+ };
311
+
312
+ const useStyles$3 = makeStyles({
313
+ section: {
314
+ display: "flex",
315
+ flexDirection: "column",
316
+ rowGap: tokens.spacingVerticalM,
317
+ },
318
+ row: { display: "flex", alignItems: "center", gap: "4px" },
319
+ });
320
+ /**
321
+ * Materials content component
322
+ * @param props - Component props
323
+ * @returns React component
324
+ */
325
+ const MaterialsContent = ({ scene }) => {
326
+ const classes = useStyles$3();
327
+ // Node Material state
328
+ const [nodeMaterialName, setNodeMaterialName] = useState("Node Material");
329
+ const [nodeMaterialSnippetId, setNodeMaterialSnippetId] = useState("");
330
+ // PBR Material state
331
+ const [pbrMaterialName, setPbrMaterialName] = useState("PBR Material");
332
+ // Standard Material state
333
+ const [standardMaterialName, setStandardMaterialName] = useState("Standard Material");
334
+ const handleCreateNodeMaterialAsync = async () => {
335
+ if (nodeMaterialSnippetId) {
336
+ try {
337
+ const nodeMaterial = await NodeMaterial.ParseFromSnippetAsync(nodeMaterialSnippetId, scene);
338
+ nodeMaterial.name = nodeMaterialName;
339
+ }
340
+ catch (e) {
341
+ alert("Failed to load Node Material from snippet: " + e);
342
+ }
343
+ }
344
+ else {
345
+ const nodeMaterial = new NodeMaterial(nodeMaterialName, scene);
346
+ nodeMaterial.build();
347
+ }
348
+ };
349
+ const handleCreatePBRMaterial = () => {
350
+ new PBRMaterial(pbrMaterialName, scene);
351
+ };
352
+ const handleCreateStandardMaterial = () => {
353
+ new StandardMaterial(standardMaterialName, scene);
354
+ };
355
+ return (jsxs("div", { className: classes.section, children: [jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: handleCreateNodeMaterialAsync, label: "Node Material" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: nodeMaterialName, onChange: (value) => setNodeMaterialName(value) }), jsx(TextInputPropertyLine, { label: "Snippet ID", value: nodeMaterialSnippetId, onChange: (value) => setNodeMaterialSnippetId(value) }), jsx(Button, { appearance: "primary", onClick: handleCreateNodeMaterialAsync, label: "Create" })] })] }), jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: handleCreatePBRMaterial, label: "PBR Material" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: pbrMaterialName, onChange: (value) => setPbrMaterialName(value) }), jsx(Button, { appearance: "primary", onClick: handleCreatePBRMaterial, label: "Create" })] })] }), jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: handleCreateStandardMaterial, label: "Standard Material" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: standardMaterialName, onChange: (value) => setStandardMaterialName(value) }), jsx(Button, { appearance: "primary", onClick: handleCreateStandardMaterial, label: "Create" })] })] })] }));
356
+ };
357
+
358
+ const useStyles$2 = makeStyles({
359
+ section: {
360
+ display: "flex",
361
+ flexDirection: "column",
362
+ rowGap: tokens.spacingVerticalM,
363
+ },
364
+ row: { display: "flex", alignItems: "center", gap: "4px" },
365
+ });
366
+ /**
367
+ * Lights content component
368
+ * @param props - Component props
369
+ * @returns React component
370
+ */
371
+ const LightsContent = ({ scene }) => {
372
+ const classes = useStyles$2();
373
+ // Point Light state
374
+ const [pointLightName, setPointLightName] = useState("Point Light");
375
+ const [pointLightPosition, setPointLightPosition] = useState(new Vector3(0, 5, 0));
376
+ // Directional Light state
377
+ const [directionalLightName, setDirectionalLightName] = useState("Directional Light");
378
+ const [directionalLightDirection, setDirectionalLightDirection] = useState(new Vector3(1, -1, 0));
379
+ // Spotlight state
380
+ const [spotlightName, setSpotlightName] = useState("Spotlight");
381
+ const [spotlightPosition, setSpotlightPosition] = useState(new Vector3(0, 5, 0));
382
+ const [spotlightDirection, setSpotlightDirection] = useState(new Vector3(0, -1, 0));
383
+ const [spotlightAngle, setSpotlightAngle] = useState(1);
384
+ const [spotlightExponent, setSpotlightExponent] = useState(1);
385
+ const handleCreatePointLight = () => {
386
+ const light = new PointLight(pointLightName, pointLightPosition, scene);
387
+ light.intensity = 1.0;
388
+ };
389
+ const handleCreateDirectionalLight = () => {
390
+ const dirLight = new DirectionalLight(directionalLightName, directionalLightDirection, scene);
391
+ dirLight.intensity = 1.0;
392
+ };
393
+ const handleCreateSpotlight = () => {
394
+ const spotlight = new SpotLight(spotlightName, spotlightPosition, spotlightDirection, spotlightAngle, spotlightExponent, scene);
395
+ spotlight.intensity = 1.0;
396
+ };
397
+ return (jsxs("div", { className: classes.section, children: [jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: handleCreatePointLight, label: "Point Light" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: pointLightName, onChange: (value) => setPointLightName(value) }), jsx(Vector3PropertyLine, { label: "Position", value: pointLightPosition, onChange: (value) => setPointLightPosition(value) }), jsx(Button, { appearance: "primary", onClick: handleCreatePointLight, label: "Create" })] })] }), jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: handleCreateDirectionalLight, label: "Directional Light" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: directionalLightName, onChange: (value) => setDirectionalLightName(value) }), jsx(Vector3PropertyLine, { label: "Direction", value: directionalLightDirection, onChange: (value) => setDirectionalLightDirection(value) }), jsx(Button, { appearance: "primary", onClick: handleCreateDirectionalLight, label: "Create" })] })] }), jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: handleCreateSpotlight, label: "Spotlight" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: spotlightName, onChange: (value) => setSpotlightName(value) }), jsx(Vector3PropertyLine, { label: "Position", value: spotlightPosition, onChange: (value) => setSpotlightPosition(value) }), jsx(Vector3PropertyLine, { label: "Direction", value: spotlightDirection, onChange: (value) => setSpotlightDirection(value) }), jsx(SpinButtonPropertyLine, { label: "Angle", value: spotlightAngle, onChange: (value) => setSpotlightAngle(value), min: 0, max: Math.PI, step: 0.1 }), jsx(SpinButtonPropertyLine, { label: "Exponent", value: spotlightExponent, onChange: (value) => setSpotlightExponent(value), min: 0, max: 10, step: 0.1 }), jsx(Button, { appearance: "primary", onClick: handleCreateSpotlight, label: "Create" })] })] })] }));
398
+ };
399
+
400
+ const useStyles$1 = makeStyles({
401
+ section: {
402
+ display: "flex",
403
+ flexDirection: "column",
404
+ rowGap: tokens.spacingVerticalM,
405
+ },
406
+ row: { display: "flex", alignItems: "center", gap: "4px" },
407
+ });
408
+ /**
409
+ * Cameras content component
410
+ * @param props - Component props
411
+ * @returns React component
412
+ */
413
+ const CamerasContent = ({ scene }) => {
414
+ const classes = useStyles$1();
415
+ // ArcRotate Camera state
416
+ const [arcRotateCameraName, setArcRotateCameraName] = useState("ArcRotate Camera");
417
+ const [arcRotateCameraTarget, setArcRotateCameraTarget] = useState(new Vector3(0, 0, 0));
418
+ const [arcRotateCameraRadius, setArcRotateCameraRadius] = useState(10);
419
+ const [arcRotateCameraAlpha, setArcRotateCameraAlpha] = useState(0);
420
+ const [arcRotateCameraBeta, setArcRotateCameraBeta] = useState(45);
421
+ const [arcRotateCameraUseRadians, setArcRotateCameraUseRadians] = useState(false);
422
+ // Universal Camera state
423
+ const [universalCameraName, setUniversalCameraName] = useState("Universal Camera");
424
+ const [universalCameraPosition, setUniversalCameraPosition] = useState(new Vector3(0, 1, -10));
425
+ const handleCreateArcRotateCamera = () => {
426
+ const alpha = arcRotateCameraUseRadians ? arcRotateCameraAlpha : (arcRotateCameraAlpha * Math.PI) / 180;
427
+ const beta = arcRotateCameraUseRadians ? arcRotateCameraBeta : (arcRotateCameraBeta * Math.PI) / 180;
428
+ const camera = new ArcRotateCamera(arcRotateCameraName, alpha, beta, arcRotateCameraRadius, arcRotateCameraTarget, scene);
429
+ camera.attachControl(scene.getEngine().getRenderingCanvas(), true);
430
+ if (!scene.activeCamera) {
431
+ scene.activeCamera = camera;
432
+ }
433
+ };
434
+ const handleCreateUniversalCamera = () => {
435
+ const camera = new UniversalCamera(universalCameraName, universalCameraPosition, scene);
436
+ camera.attachControl(scene.getEngine().getRenderingCanvas(), true);
437
+ if (!scene.activeCamera) {
438
+ scene.activeCamera = camera;
439
+ }
440
+ };
441
+ return (jsxs("div", { className: classes.section, children: [jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: handleCreateArcRotateCamera, label: "ArcRotate Camera" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: arcRotateCameraName, onChange: (value) => setArcRotateCameraName(value) }), jsx(Vector3PropertyLine, { label: "Target", value: arcRotateCameraTarget, onChange: (value) => setArcRotateCameraTarget(value) }), jsx(SpinButtonPropertyLine, { label: "Radius", value: arcRotateCameraRadius, onChange: (value) => setArcRotateCameraRadius(value), min: 0.1, max: 1000, step: 0.5 }), jsx(SpinButtonPropertyLine, { label: `Alpha ${arcRotateCameraUseRadians ? "(rad)" : "(deg)"}`, value: arcRotateCameraAlpha, onChange: (value) => setArcRotateCameraAlpha(value), min: arcRotateCameraUseRadians ? -Math.PI * 2 : -360, max: arcRotateCameraUseRadians ? Math.PI * 2 : 360, step: arcRotateCameraUseRadians ? 0.1 : 5 }), jsx(SpinButtonPropertyLine, { label: `Beta ${arcRotateCameraUseRadians ? "(rad)" : "(deg)"}`, value: arcRotateCameraBeta, onChange: (value) => setArcRotateCameraBeta(value), min: arcRotateCameraUseRadians ? 0 : 0, max: arcRotateCameraUseRadians ? Math.PI : 180, step: arcRotateCameraUseRadians ? 0.1 : 5 }), jsx(CheckboxPropertyLine, { label: "Use Radians", value: arcRotateCameraUseRadians, onChange: (value) => setArcRotateCameraUseRadians(value) }), jsx(Button, { appearance: "primary", onClick: handleCreateArcRotateCamera, label: "Create" })] })] }), jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: handleCreateUniversalCamera, label: "Universal Camera" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: universalCameraName, onChange: (value) => setUniversalCameraName(value) }), jsx(Vector3PropertyLine, { label: "Position", value: universalCameraPosition, onChange: (value) => setUniversalCameraPosition(value) }), jsx(Button, { appearance: "primary", onClick: handleCreateUniversalCamera, label: "Create" })] })] })] }));
442
+ };
443
+
444
+ const useStyles = makeStyles({
445
+ section: {
446
+ display: "flex",
447
+ flexDirection: "column",
448
+ rowGap: tokens.spacingVerticalM,
449
+ },
450
+ row: { display: "flex", alignItems: "center", gap: "4px" },
451
+ });
452
+ /**
453
+ * Particles content component
454
+ * @param props - Component props
455
+ * @returns React component
456
+ */
457
+ const ParticlesContent = ({ scene }) => {
458
+ const classes = useStyles();
459
+ // CPU Particle System state
460
+ const [cpuParticleSystemName, setCpuParticleSystemName] = useState("Particle System");
461
+ const [cpuParticleSystemCapacity, setCpuParticleSystemCapacity] = useState(2000);
462
+ // GPU Particle System state
463
+ const [gpuParticleSystemName, setGpuParticleSystemName] = useState("GPU Particle System");
464
+ const [gpuParticleSystemCapacity, setGpuParticleSystemCapacity] = useState(2000);
465
+ // Node Particle System state
466
+ const [nodeParticleSystemName, setNodeParticleSystemName] = useState("Node Particle System");
467
+ const [nodeParticleSystemSnippetId, setNodeParticleSystemSnippetId] = useState("");
468
+ const handleCreateCPUParticleSystem = () => {
469
+ setTimeout(() => {
470
+ const system = new ParticleSystem(cpuParticleSystemName, cpuParticleSystemCapacity, scene);
471
+ system.particleTexture = new Texture("https://assets.babylonjs.com/textures/flare.png", scene);
472
+ system.start();
473
+ }, 0);
474
+ };
475
+ const handleCreateGPUParticleSystem = () => {
476
+ if (GPUParticleSystem.IsSupported) {
477
+ setTimeout(() => {
478
+ const system = new GPUParticleSystem(gpuParticleSystemName, { capacity: gpuParticleSystemCapacity }, scene);
479
+ system.particleTexture = new Texture("https://assets.babylonjs.com/textures/flare.png", scene);
480
+ system.start();
481
+ }, 0);
482
+ }
483
+ else {
484
+ alert("GPU Particle System is not supported.");
485
+ }
486
+ };
487
+ const handleCreateNodeParticleSystemAsync = async () => {
488
+ try {
489
+ let nodeParticleSet;
490
+ const snippetId = nodeParticleSystemSnippetId.trim();
491
+ if (snippetId) {
492
+ nodeParticleSet = await NodeParticleSystemSet.ParseFromSnippetAsync(snippetId);
493
+ nodeParticleSet.name = nodeParticleSystemName;
494
+ }
495
+ else {
496
+ nodeParticleSet = NodeParticleSystemSet.CreateDefault(nodeParticleSystemName);
497
+ }
498
+ const particleSystemSet = await nodeParticleSet.buildAsync(scene);
499
+ for (const system of particleSystemSet.systems) {
500
+ system.name = nodeParticleSystemName;
501
+ }
502
+ particleSystemSet.start();
503
+ }
504
+ catch (e) {
505
+ global.console.error("Error creating Node Particle System:", e);
506
+ alert("Failed to create Node Particle System: " + e);
507
+ }
508
+ };
509
+ return (jsxs("div", { className: classes.section, children: [jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: handleCreateCPUParticleSystem, label: "CPU Particle System" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: cpuParticleSystemName, onChange: (value) => setCpuParticleSystemName(value) }), jsx(SpinButtonPropertyLine, { label: "Capacity", value: cpuParticleSystemCapacity, onChange: (value) => setCpuParticleSystemCapacity(value), min: 1, max: 100000, step: 100 }), jsx(Button, { appearance: "primary", onClick: handleCreateCPUParticleSystem, label: "Create" })] })] }), jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: handleCreateGPUParticleSystem, label: "GPU Particle System" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: gpuParticleSystemName, onChange: (value) => setGpuParticleSystemName(value) }), jsx(SpinButtonPropertyLine, { label: "Capacity", value: gpuParticleSystemCapacity, onChange: (value) => setGpuParticleSystemCapacity(value), min: 1, max: 1000000, step: 1000 }), jsx(Button, { appearance: "primary", onClick: handleCreateGPUParticleSystem, label: "Create" })] })] }), jsxs("div", { className: classes.row, children: [jsx(Button, { onClick: handleCreateNodeParticleSystemAsync, label: "Node Particle System" }), jsxs(SettingsPopover, { children: [jsx(TextInputPropertyLine, { label: "Name", value: nodeParticleSystemName, onChange: (value) => setNodeParticleSystemName(value) }), jsx(TextInputPropertyLine, { label: "Snippet ID", value: nodeParticleSystemSnippetId, onChange: (value) => setNodeParticleSystemSnippetId(value) }), jsx(Button, { appearance: "primary", onClick: handleCreateNodeParticleSystemAsync, label: "Create" })] })] })] }));
510
+ };
511
+
512
+ // TODO: This is just a placeholder for a dynamically installed extension that brings in asset creation tools (node materials, etc.).
513
+ const CreateToolsServiceDefinition = {
514
+ friendlyName: "Creation Tools",
515
+ consumes: [ShellServiceIdentity, SceneContextIdentity],
516
+ factory: (shellService, sceneContext) => {
517
+ const registration = shellService.addSidePane({
518
+ key: "Create",
519
+ title: "Creation Tools",
520
+ icon: CollectionsAdd20Regular,
521
+ horizontalLocation: "left",
522
+ verticalLocation: "top",
523
+ content: () => {
524
+ const scene = useObservableState(() => sceneContext.currentScene, sceneContext.currentSceneObservable);
525
+ return (scene && (jsx(Fragment, { children: jsxs(Accordion, { children: [jsx(AccordionSection, { title: "Meshes", children: jsx(MeshesContent, { scene: scene }) }), jsx(AccordionSection, { title: "Materials", children: jsx(MaterialsContent, { scene: scene }) }), jsx(AccordionSection, { title: "Lights", children: jsx(LightsContent, { scene: scene }) }), jsx(AccordionSection, { title: "Particles", children: jsx(ParticlesContent, { scene: scene }) }), jsx(AccordionSection, { title: "Cameras", children: jsx(CamerasContent, { scene: scene }) })] }) })));
526
+ },
527
+ });
528
+ return {
529
+ dispose: () => registration.dispose(),
530
+ };
531
+ },
532
+ };
533
+ var quickCreateToolsService = {
534
+ serviceDefinitions: [CreateToolsServiceDefinition],
535
+ };
536
+
537
+ export { CreateToolsServiceDefinition, quickCreateToolsService as default };
538
+ //# sourceMappingURL=quickCreateToolsService-DEdXDqIl.js.map