@fps-games/editor 0.1.1-beta.6 → 0.1.1-beta.7
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/dist/local-editor-harness.d.ts +14 -3
- package/dist/local-editor-harness.d.ts.map +1 -1
- package/dist/local-editor-harness.js +205 -35
- package/dist/local-editor-harness.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/editor-sky.d.ts +33 -0
- package/node_modules/@fps-games/editor-babylon/dist/editor-sky.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/editor-sky.js +231 -0
- package/node_modules/@fps-games/editor-babylon/dist/editor-sky.js.map +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/editor-world.d.ts +3 -0
- package/node_modules/@fps-games/editor-babylon/dist/editor-world.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/editor-world.js +8 -0
- package/node_modules/@fps-games/editor-babylon/dist/editor-world.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/index.d.ts +2 -0
- package/node_modules/@fps-games/editor-babylon/dist/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/index.js +2 -0
- package/node_modules/@fps-games/editor-babylon/dist/index.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/infinite-grid.d.ts +40 -0
- package/node_modules/@fps-games/editor-babylon/dist/infinite-grid.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/infinite-grid.js +237 -0
- package/node_modules/@fps-games/editor-babylon/dist/infinite-grid.js.map +1 -0
- package/node_modules/@fps-games/editor-babylon/dist/projection-selection-controller.d.ts +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/projection-selection-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/projection-selection-controller.js +15 -50
- package/node_modules/@fps-games/editor-babylon/dist/projection-selection-controller.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/projection.d.ts +5 -0
- package/node_modules/@fps-games/editor-babylon/dist/projection.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/projection.js +61 -8
- package/node_modules/@fps-games/editor-babylon/dist/projection.js.map +1 -1
- package/node_modules/@fps-games/editor-babylon/dist/types.d.ts +7 -0
- package/node_modules/@fps-games/editor-babylon/dist/types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-babylon/package.json +4 -4
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-context-menu.js +97 -46
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-context-menu.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-actions.d.ts +5 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-actions.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-actions.js +57 -7
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-actions.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.js +61 -5
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-tree.js +0 -2
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-tree.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.js +6 -2
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-view.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.d.ts +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.js +16 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.d.ts +8 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.js +358 -53
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-panels.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shared.d.ts +5 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shared.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shared.js +28 -8
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shared.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shortcuts.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shortcuts.js +4 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-shortcuts.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-theme.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-theme.js +14 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-theme.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-tooltip.d.ts +11 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-tooltip.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-tooltip.js +148 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-tooltip.js.map +1 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.d.ts +42 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.d.ts +5 -4
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.js +606 -199
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/package.json +2 -2
- package/node_modules/@fps-games/editor-core/dist/index.d.ts +1 -0
- package/node_modules/@fps-games/editor-core/dist/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/index.js +1 -0
- package/node_modules/@fps-games/editor-core/dist/index.js.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/inspector.d.ts +6 -1
- package/node_modules/@fps-games/editor-core/dist/inspector.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/inspector.js +6 -1
- package/node_modules/@fps-games/editor-core/dist/inspector.js.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/scene-graph.d.ts +7 -0
- package/node_modules/@fps-games/editor-core/dist/scene-graph.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/scene-graph.js.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/selection-strategy.d.ts +12 -0
- package/node_modules/@fps-games/editor-core/dist/selection-strategy.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-core/dist/selection-strategy.js +52 -0
- package/node_modules/@fps-games/editor-core/dist/selection-strategy.js.map +1 -0
- package/node_modules/@fps-games/editor-core/package.json +2 -2
- package/node_modules/@fps-games/editor-forge-play/package.json +2 -2
- package/node_modules/@fps-games/editor-protocol/package.json +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
const DEFAULT_EDITOR_SKY = {
|
|
2
|
+
enabled: true,
|
|
3
|
+
radius: 1200,
|
|
4
|
+
topColor: { r: 0.28, g: 0.58, b: 0.86 },
|
|
5
|
+
horizonColor: { r: 0.72, g: 0.83, b: 0.88 },
|
|
6
|
+
bottomColor: { r: 0.56, g: 0.62, b: 0.64 },
|
|
7
|
+
cloudColor: { r: 1, g: 0.96, b: 0.86 },
|
|
8
|
+
cloudStrength: 0.42,
|
|
9
|
+
sunColor: { r: 1, g: 0.86, b: 0.58 },
|
|
10
|
+
sunDirection: { x: -0.36, y: 0.42, z: -0.82 },
|
|
11
|
+
};
|
|
12
|
+
const POSITION_KIND = 'position';
|
|
13
|
+
const COLOR_KIND = 'color';
|
|
14
|
+
const SKY_SHADER_NAME = 'editorSkyBackdrop';
|
|
15
|
+
const SKY_VERTEX_SHADER = `
|
|
16
|
+
precision highp float;
|
|
17
|
+
attribute vec3 position;
|
|
18
|
+
uniform mat4 worldViewProjection;
|
|
19
|
+
varying vec3 vDirection;
|
|
20
|
+
void main(void) {
|
|
21
|
+
vDirection = normalize(position);
|
|
22
|
+
gl_Position = worldViewProjection * vec4(position, 1.0);
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
const SKY_FRAGMENT_SHADER = `
|
|
26
|
+
precision highp float;
|
|
27
|
+
varying vec3 vDirection;
|
|
28
|
+
uniform vec3 topColor;
|
|
29
|
+
uniform vec3 horizonColor;
|
|
30
|
+
uniform vec3 bottomColor;
|
|
31
|
+
uniform vec3 cloudColor;
|
|
32
|
+
uniform vec3 sunColor;
|
|
33
|
+
uniform vec3 sunDirection;
|
|
34
|
+
uniform float cloudStrength;
|
|
35
|
+
|
|
36
|
+
float hash(vec2 p) {
|
|
37
|
+
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
float valueNoise(vec2 p) {
|
|
41
|
+
vec2 i = floor(p);
|
|
42
|
+
vec2 f = fract(p);
|
|
43
|
+
vec2 u = f * f * (3.0 - 2.0 * f);
|
|
44
|
+
float a = hash(i);
|
|
45
|
+
float b = hash(i + vec2(1.0, 0.0));
|
|
46
|
+
float c = hash(i + vec2(0.0, 1.0));
|
|
47
|
+
float d = hash(i + vec2(1.0, 1.0));
|
|
48
|
+
return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
float cloudNoise(vec2 p) {
|
|
52
|
+
float n = valueNoise(p * 1.0) * 0.56;
|
|
53
|
+
n += valueNoise(p * 2.2 + vec2(3.1, 1.7)) * 0.28;
|
|
54
|
+
n += valueNoise(p * 4.1 + vec2(8.3, 4.4)) * 0.16;
|
|
55
|
+
return n;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void main(void) {
|
|
59
|
+
vec3 dir = normalize(vDirection);
|
|
60
|
+
float h = clamp(dir.y * 0.5 + 0.5, 0.0, 1.0);
|
|
61
|
+
vec3 lowerSky = mix(bottomColor, horizonColor, smoothstep(0.0, 0.52, h));
|
|
62
|
+
vec3 upperSky = mix(horizonColor, topColor, smoothstep(0.38, 1.0, h));
|
|
63
|
+
vec3 sky = mix(lowerSky, upperSky, smoothstep(0.32, 0.76, h));
|
|
64
|
+
|
|
65
|
+
float horizonMist = 1.0 - smoothstep(0.015, 0.26, abs(dir.y));
|
|
66
|
+
sky += horizonMist * vec3(0.08, 0.09, 0.08);
|
|
67
|
+
|
|
68
|
+
float sunDot = max(dot(dir, normalize(sunDirection)), 0.0);
|
|
69
|
+
float sunGlow = pow(sunDot, 48.0) * 0.32 + pow(sunDot, 420.0) * 0.78;
|
|
70
|
+
sky = mix(sky, sunColor, clamp(sunGlow, 0.0, 0.72));
|
|
71
|
+
|
|
72
|
+
float cloudBand = smoothstep(0.05, 0.24, dir.y) * (1.0 - smoothstep(0.58, 0.82, dir.y));
|
|
73
|
+
vec2 cloudUv = dir.xz / max(dir.y + 0.48, 0.18);
|
|
74
|
+
float stretchedNoise = cloudNoise(vec2(cloudUv.x * 1.25, cloudUv.y * 0.34));
|
|
75
|
+
float streaks = smoothstep(0.56, 0.82, stretchedNoise) * cloudBand * cloudStrength;
|
|
76
|
+
sky = mix(sky, cloudColor, clamp(streaks, 0.0, 0.48));
|
|
77
|
+
|
|
78
|
+
gl_FragColor = vec4(clamp(sky, 0.0, 1.0), 1.0);
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
export function createBabylonEditorSkyBackdrop(options) {
|
|
82
|
+
const sky = resolveEditorSkyOptions(options.sky);
|
|
83
|
+
if (!sky.enabled)
|
|
84
|
+
return null;
|
|
85
|
+
const MeshBuilder = options.babylon.MeshBuilder;
|
|
86
|
+
const Color3 = options.babylon.Color3;
|
|
87
|
+
if (!MeshBuilder?.CreateSphere || !Color3)
|
|
88
|
+
return null;
|
|
89
|
+
const mesh = MeshBuilder.CreateSphere('editor.world.sky', {
|
|
90
|
+
diameter: sky.radius * 2,
|
|
91
|
+
segments: 32,
|
|
92
|
+
sideOrientation: options.babylon.Mesh?.BACKSIDE ?? 1,
|
|
93
|
+
}, options.scene);
|
|
94
|
+
mesh.isPickable = false;
|
|
95
|
+
mesh.infiniteDistance = true;
|
|
96
|
+
mesh.alwaysSelectAsActiveMesh = true;
|
|
97
|
+
mesh.doNotSyncBoundingInfo = true;
|
|
98
|
+
const skyMaterial = createSkyMaterial(options.babylon, options.scene, sky, canUseSkyShader(options.babylon));
|
|
99
|
+
if (!skyMaterial) {
|
|
100
|
+
mesh.dispose?.();
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
const { material, shader } = skyMaterial;
|
|
104
|
+
mesh.material = material;
|
|
105
|
+
if (!shader) {
|
|
106
|
+
applySkyVertexColors(mesh, sky);
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
mesh,
|
|
110
|
+
material,
|
|
111
|
+
dispose() {
|
|
112
|
+
mesh.dispose?.();
|
|
113
|
+
material.dispose?.();
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function createSkyMaterial(babylon, scene, sky, preferShader) {
|
|
118
|
+
if (preferShader) {
|
|
119
|
+
try {
|
|
120
|
+
const shaderMaterial = createSkyShaderMaterial(babylon, scene, sky);
|
|
121
|
+
if (shaderMaterial)
|
|
122
|
+
return { material: shaderMaterial, shader: true };
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
// Fallback below keeps editor preview usable on older Babylon runtimes.
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const fallbackMaterial = createSkyVertexColorMaterial(babylon, scene);
|
|
129
|
+
return fallbackMaterial ? { material: fallbackMaterial, shader: false } : null;
|
|
130
|
+
}
|
|
131
|
+
function createSkyShaderMaterial(babylon, scene, sky) {
|
|
132
|
+
if (!canUseSkyShader(babylon))
|
|
133
|
+
return null;
|
|
134
|
+
const ShaderMaterial = babylon.ShaderMaterial;
|
|
135
|
+
const Color3 = babylon.Color3;
|
|
136
|
+
const Vector3 = babylon.Vector3;
|
|
137
|
+
const store = babylon.Effect.ShadersStore;
|
|
138
|
+
store[`${SKY_SHADER_NAME}VertexShader`] = SKY_VERTEX_SHADER;
|
|
139
|
+
store[`${SKY_SHADER_NAME}FragmentShader`] = SKY_FRAGMENT_SHADER;
|
|
140
|
+
const material = new ShaderMaterial('editor.world.sky.shaderMaterial', scene, { vertex: SKY_SHADER_NAME, fragment: SKY_SHADER_NAME }, {
|
|
141
|
+
attributes: ['position'],
|
|
142
|
+
uniforms: [
|
|
143
|
+
'worldViewProjection',
|
|
144
|
+
'topColor',
|
|
145
|
+
'horizonColor',
|
|
146
|
+
'bottomColor',
|
|
147
|
+
'cloudColor',
|
|
148
|
+
'sunColor',
|
|
149
|
+
'sunDirection',
|
|
150
|
+
'cloudStrength',
|
|
151
|
+
],
|
|
152
|
+
});
|
|
153
|
+
material.backFaceCulling = false;
|
|
154
|
+
material.disableDepthWrite = true;
|
|
155
|
+
material.setColor3?.('topColor', toColor3(Color3, sky.topColor));
|
|
156
|
+
material.setColor3?.('horizonColor', toColor3(Color3, sky.horizonColor));
|
|
157
|
+
material.setColor3?.('bottomColor', toColor3(Color3, sky.bottomColor));
|
|
158
|
+
material.setColor3?.('cloudColor', toColor3(Color3, sky.cloudColor));
|
|
159
|
+
material.setColor3?.('sunColor', toColor3(Color3, sky.sunColor));
|
|
160
|
+
if (Vector3 && material.setVector3) {
|
|
161
|
+
material.setVector3('sunDirection', new Vector3(sky.sunDirection.x, sky.sunDirection.y, sky.sunDirection.z));
|
|
162
|
+
}
|
|
163
|
+
material.setFloat?.('cloudStrength', sky.cloudStrength);
|
|
164
|
+
return material;
|
|
165
|
+
}
|
|
166
|
+
function canUseSkyShader(babylon) {
|
|
167
|
+
return (!!babylon.ShaderMaterial
|
|
168
|
+
&& !!babylon.Color3
|
|
169
|
+
&& !!babylon.Effect?.ShadersStore);
|
|
170
|
+
}
|
|
171
|
+
function createSkyVertexColorMaterial(babylon, scene) {
|
|
172
|
+
const StandardMaterial = babylon.StandardMaterial;
|
|
173
|
+
const Color3 = babylon.Color3;
|
|
174
|
+
if (!StandardMaterial || !Color3)
|
|
175
|
+
return null;
|
|
176
|
+
const material = new StandardMaterial('editor.world.sky.material', scene);
|
|
177
|
+
material.disableLighting = true;
|
|
178
|
+
material.backFaceCulling = false;
|
|
179
|
+
material.useVertexColors = true;
|
|
180
|
+
material.diffuseColor = new Color3(1, 1, 1);
|
|
181
|
+
material.emissiveColor = new Color3(1, 1, 1);
|
|
182
|
+
material.specularColor = new Color3(0, 0, 0);
|
|
183
|
+
material.freeze?.();
|
|
184
|
+
return material;
|
|
185
|
+
}
|
|
186
|
+
function resolveEditorSkyOptions(sky) {
|
|
187
|
+
if (sky === false)
|
|
188
|
+
return { ...DEFAULT_EDITOR_SKY, enabled: false };
|
|
189
|
+
return {
|
|
190
|
+
enabled: sky?.enabled ?? DEFAULT_EDITOR_SKY.enabled,
|
|
191
|
+
radius: sky?.radius ?? DEFAULT_EDITOR_SKY.radius,
|
|
192
|
+
topColor: sky?.topColor ?? DEFAULT_EDITOR_SKY.topColor,
|
|
193
|
+
horizonColor: sky?.horizonColor ?? DEFAULT_EDITOR_SKY.horizonColor,
|
|
194
|
+
bottomColor: sky?.bottomColor ?? DEFAULT_EDITOR_SKY.bottomColor,
|
|
195
|
+
cloudColor: sky?.cloudColor ?? DEFAULT_EDITOR_SKY.cloudColor,
|
|
196
|
+
cloudStrength: sky?.cloudStrength ?? DEFAULT_EDITOR_SKY.cloudStrength,
|
|
197
|
+
sunColor: sky?.sunColor ?? DEFAULT_EDITOR_SKY.sunColor,
|
|
198
|
+
sunDirection: sky?.sunDirection ?? DEFAULT_EDITOR_SKY.sunDirection,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function applySkyVertexColors(mesh, sky) {
|
|
202
|
+
const positions = mesh.getVerticesData?.(POSITION_KIND);
|
|
203
|
+
if (!positions || !mesh.setVerticesData)
|
|
204
|
+
return;
|
|
205
|
+
const colors = [];
|
|
206
|
+
for (let index = 0; index < positions.length; index += 3) {
|
|
207
|
+
const normalizedY = clamp01((positions[index + 1] / sky.radius + 1) / 2);
|
|
208
|
+
const color = normalizedY < 0.5
|
|
209
|
+
? mixColor(sky.bottomColor, sky.horizonColor, normalizedY / 0.5)
|
|
210
|
+
: mixColor(sky.horizonColor, sky.topColor, (normalizedY - 0.5) / 0.5);
|
|
211
|
+
colors.push(color.r, color.g, color.b, 1);
|
|
212
|
+
}
|
|
213
|
+
mesh.setVerticesData(COLOR_KIND, colors, false);
|
|
214
|
+
}
|
|
215
|
+
function mixColor(from, to, amount) {
|
|
216
|
+
const t = clamp01(amount);
|
|
217
|
+
return {
|
|
218
|
+
r: from.r + (to.r - from.r) * t,
|
|
219
|
+
g: from.g + (to.g - from.g) * t,
|
|
220
|
+
b: from.b + (to.b - from.b) * t,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function clamp01(value) {
|
|
224
|
+
if (!Number.isFinite(value))
|
|
225
|
+
return 0;
|
|
226
|
+
return Math.max(0, Math.min(1, value));
|
|
227
|
+
}
|
|
228
|
+
function toColor3(Color3, color) {
|
|
229
|
+
return new Color3(color.r, color.g, color.b);
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=editor-sky.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-sky.js","sourceRoot":"","sources":["../src/editor-sky.ts"],"names":[],"mappings":"AAmCA,MAAM,kBAAkB,GAAsC;IAC5D,OA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AC;AAED,SAAS,QAAQ,CACf,IAA2B,EAC3B,EAAyB,EACzB,MAAc;IAEd,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1B,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;QAC/B,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;QAC/B,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;KAChC,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,KAAa;IAC5B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,QAAQ,CACf,MAAoD,EACpD,KAA4B;IAE5B,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BabylonRuntimeGlobal, RuntimeCamera, RuntimeScene } from './types';
|
|
2
|
+
import { type BabylonEditorSkyBackdrop, type BabylonEditorSkyOptions } from './editor-sky';
|
|
2
3
|
export interface BabylonEditorWorldOptions {
|
|
3
4
|
engine: any;
|
|
4
5
|
canvas?: HTMLCanvasElement | null;
|
|
@@ -15,6 +16,7 @@ export interface BabylonEditorWorldOptions {
|
|
|
15
16
|
b: number;
|
|
16
17
|
a: number;
|
|
17
18
|
};
|
|
19
|
+
sky?: BabylonEditorSkyOptions | false;
|
|
18
20
|
useRightHandedSystem?: boolean;
|
|
19
21
|
enableGizmoManager?: boolean;
|
|
20
22
|
enableDefaultCameraControls?: boolean;
|
|
@@ -23,6 +25,7 @@ export interface BabylonEditorWorld {
|
|
|
23
25
|
scene: RuntimeScene;
|
|
24
26
|
camera: RuntimeCamera;
|
|
25
27
|
gizmoManager: any | null;
|
|
28
|
+
skyBackdrop: BabylonEditorSkyBackdrop | null;
|
|
26
29
|
render(): void;
|
|
27
30
|
dispose(): void;
|
|
28
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-world.d.ts","sourceRoot":"","sources":["../src/editor-world.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"editor-world.d.ts","sourceRoot":"","sources":["../src/editor-world.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC7B,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,GAAG,CAAC;IACZ,MAAM,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAClC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,YAAY,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5D,GAAG,CAAC,EAAE,uBAAuB,GAAG,KAAK,CAAC;IACtC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,EAAE,GAAG,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC7C,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,IAAI,IAAI,CAAC;CACjB;AAOD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,kBAAkB,CA0E/F"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createBabylonEditorSkyBackdrop, } from './editor-sky';
|
|
1
2
|
function requireBabylonCtor(value, name) {
|
|
2
3
|
if (!value)
|
|
3
4
|
throw new Error(`Babylon runtime missing ${name}`);
|
|
@@ -13,6 +14,11 @@ export function createBabylonEditorWorld(options) {
|
|
|
13
14
|
if (options.clearColor && options.babylon.Color4) {
|
|
14
15
|
scene.clearColor = new options.babylon.Color4(options.clearColor.r, options.clearColor.g, options.clearColor.b, options.clearColor.a);
|
|
15
16
|
}
|
|
17
|
+
const skyBackdrop = createBabylonEditorSkyBackdrop({
|
|
18
|
+
babylon: options.babylon,
|
|
19
|
+
scene,
|
|
20
|
+
sky: options.sky,
|
|
21
|
+
});
|
|
16
22
|
const target = options.cameraTarget ?? { x: 0, y: 0.8, z: 0 };
|
|
17
23
|
let camera;
|
|
18
24
|
if (options.babylon.ArcRotateCamera) {
|
|
@@ -38,10 +44,12 @@ export function createBabylonEditorWorld(options) {
|
|
|
38
44
|
scene,
|
|
39
45
|
camera,
|
|
40
46
|
gizmoManager,
|
|
47
|
+
skyBackdrop,
|
|
41
48
|
render() {
|
|
42
49
|
scene.render();
|
|
43
50
|
},
|
|
44
51
|
dispose() {
|
|
52
|
+
skyBackdrop?.dispose();
|
|
45
53
|
gizmoManager?.dispose?.();
|
|
46
54
|
scene.dispose();
|
|
47
55
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-world.js","sourceRoot":"","sources":["../src/editor-world.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"editor-world.js","sourceRoot":"","sources":["../src/editor-world.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,8BAA8B,GAG/B,MAAM,cAAc,CAAC;AAwBtB,SAAS,kBAAkB,CAAI,KAAoB,EAAE,IAAY;IAC/D,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,EAAE,CAAC,CAAC;IAC/D,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,OAAkC;IACzE,MAAM,SAAS,GAAG,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACrE,MAAM,WAAW,GAAG,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAE3E,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,OAAO,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QAC/C,KAAK,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAC5D,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACjD,KAAK,CAAC,UAAU,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAC3C,OAAO,CAAC,UAAU,CAAC,CAAC,EACpB,OAAO,CAAC,UAAU,CAAC,CAAC,EACpB,OAAO,CAAC,UAAU,CAAC,CAAC,EACpB,OAAO,CAAC,UAAU,CAAC,CAAC,CACrB,CAAC;IAC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ACD,IAAI,CAAC;QAAE,MAAc,CAAC,kBAAkB,GAAG,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AAC1D,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export * from './camera-controller';
|
|
2
2
|
export * from './edit-session';
|
|
3
3
|
export * from './editor-world';
|
|
4
|
+
export * from './editor-sky';
|
|
4
5
|
export * from './event-guard';
|
|
5
6
|
export * from './input-controller';
|
|
6
7
|
export * from './inspector-adapter';
|
|
7
8
|
export * from './inspector-host';
|
|
9
|
+
export * from './infinite-grid';
|
|
8
10
|
export * from './material-property-adapter';
|
|
9
11
|
export * from './monitor';
|
|
10
12
|
export * from './outline-adapter';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,mBAAmB,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,mBAAmB,SAAS,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export * from './camera-controller';
|
|
2
2
|
export * from './edit-session';
|
|
3
3
|
export * from './editor-world';
|
|
4
|
+
export * from './editor-sky';
|
|
4
5
|
export * from './event-guard';
|
|
5
6
|
export * from './input-controller';
|
|
6
7
|
export * from './inspector-adapter';
|
|
7
8
|
export * from './inspector-host';
|
|
9
|
+
export * from './infinite-grid';
|
|
8
10
|
export * from './material-property-adapter';
|
|
9
11
|
export * from './monitor';
|
|
10
12
|
export * from './outline-adapter';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { BabylonRuntimeGlobal, RuntimeCamera, RuntimeScene } from './types';
|
|
2
|
+
export interface BabylonEditorInfiniteGridOptions {
|
|
3
|
+
babylon: BabylonRuntimeGlobal & Record<string, any>;
|
|
4
|
+
scene: RuntimeScene;
|
|
5
|
+
camera?: RuntimeCamera | null;
|
|
6
|
+
name?: string;
|
|
7
|
+
step?: number;
|
|
8
|
+
adaptiveSteps?: number[];
|
|
9
|
+
targetScreenSpacingPx?: number;
|
|
10
|
+
majorStep?: number;
|
|
11
|
+
halfLineCount?: number;
|
|
12
|
+
gridColor?: {
|
|
13
|
+
r: number;
|
|
14
|
+
g: number;
|
|
15
|
+
b: number;
|
|
16
|
+
};
|
|
17
|
+
majorGridColor?: {
|
|
18
|
+
r: number;
|
|
19
|
+
g: number;
|
|
20
|
+
b: number;
|
|
21
|
+
};
|
|
22
|
+
axisXColor?: {
|
|
23
|
+
r: number;
|
|
24
|
+
g: number;
|
|
25
|
+
b: number;
|
|
26
|
+
};
|
|
27
|
+
axisZColor?: {
|
|
28
|
+
r: number;
|
|
29
|
+
g: number;
|
|
30
|
+
b: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface BabylonEditorGridController {
|
|
34
|
+
setVisible(visible: boolean): void;
|
|
35
|
+
isVisible(): boolean;
|
|
36
|
+
getStep(): number;
|
|
37
|
+
dispose(): void;
|
|
38
|
+
}
|
|
39
|
+
export declare function createBabylonEditorInfiniteGrid(options: BabylonEditorInfiniteGridOptions): BabylonEditorGridController;
|
|
40
|
+
//# sourceMappingURL=infinite-grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infinite-grid.d.ts","sourceRoot":"","sources":["../src/infinite-grid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,gCAAgC;IAC/C,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpD,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,cAAc,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,UAAU,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,UAAU,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAClD;AAED,MAAM,WAAW,2BAA2B;IAC1C,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACnC,SAAS,IAAI,OAAO,CAAC;IACrB,OAAO,IAAI,MAAM,CAAC;IAClB,OAAO,IAAI,IAAI,CAAC;CACjB;AAsCD,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,gCAAgC,GACxC,2BAA2B,CA6H7B"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
const DEFAULT_STEP = 1;
|
|
2
|
+
const DEFAULT_MAJOR_STEP_MULTIPLIER = 5;
|
|
3
|
+
const DEFAULT_HALF_LINE_COUNT = 80;
|
|
4
|
+
const DEFAULT_TARGET_SCREEN_SPACING_PX = 48;
|
|
5
|
+
const DEFAULT_ADAPTIVE_STEPS = [
|
|
6
|
+
1,
|
|
7
|
+
5,
|
|
8
|
+
10,
|
|
9
|
+
50,
|
|
10
|
+
100,
|
|
11
|
+
500,
|
|
12
|
+
1000,
|
|
13
|
+
5000,
|
|
14
|
+
10000,
|
|
15
|
+
50000,
|
|
16
|
+
100000,
|
|
17
|
+
];
|
|
18
|
+
export function createBabylonEditorInfiniteGrid(options) {
|
|
19
|
+
const MeshBuilder = options.babylon.MeshBuilder;
|
|
20
|
+
const Vector3 = options.babylon.Vector3;
|
|
21
|
+
const Color3 = options.babylon.Color3;
|
|
22
|
+
const scene = options.scene;
|
|
23
|
+
if (!scene || !MeshBuilder?.CreateLines || !Vector3 || !Color3)
|
|
24
|
+
return createNoopGridController();
|
|
25
|
+
const minStep = normalizePositive(options.step, DEFAULT_STEP);
|
|
26
|
+
const adaptiveSteps = normalizeAdaptiveSteps(options.adaptiveSteps, minStep);
|
|
27
|
+
const targetScreenSpacingPx = normalizePositive(options.targetScreenSpacingPx, DEFAULT_TARGET_SCREEN_SPACING_PX);
|
|
28
|
+
const halfLineCount = Math.max(4, Math.floor(normalizePositive(options.halfLineCount, DEFAULT_HALF_LINE_COUNT)));
|
|
29
|
+
const name = options.name ?? 'editor-infinite-grid';
|
|
30
|
+
const gridColor = createColor(Color3, options.gridColor ?? { r: 0.18, g: 0.27, b: 0.42 });
|
|
31
|
+
const majorGridColor = createColor(Color3, options.majorGridColor ?? { r: 0.24, g: 0.36, b: 0.56 });
|
|
32
|
+
const axisXColor = createColor(Color3, options.axisXColor ?? { r: 0.8, g: 0.22, b: 0.22 });
|
|
33
|
+
const axisZColor = createColor(Color3, options.axisZColor ?? { r: 0.22, g: 0.55, b: 0.85 });
|
|
34
|
+
const lines = [];
|
|
35
|
+
let visible = true;
|
|
36
|
+
let disposed = false;
|
|
37
|
+
let currentStep = minStep;
|
|
38
|
+
let lastFrameState = null;
|
|
39
|
+
let renderObserver = null;
|
|
40
|
+
for (let offsetIndex = -halfLineCount; offsetIndex <= halfLineCount; offsetIndex += 1) {
|
|
41
|
+
lines.push(createGridLine('x', offsetIndex));
|
|
42
|
+
lines.push(createGridLine('z', offsetIndex));
|
|
43
|
+
}
|
|
44
|
+
updateGrid(true);
|
|
45
|
+
renderObserver = scene.onBeforeRenderObservable?.add?.(() => updateGrid(false)) ?? null;
|
|
46
|
+
function createGridLine(direction, offsetIndex) {
|
|
47
|
+
const mesh = MeshBuilder.CreateLines(`${name}-${direction}-${offsetIndex}`, {
|
|
48
|
+
points: [new Vector3(0, 0, 0), new Vector3(0, 0, 0)],
|
|
49
|
+
updatable: true,
|
|
50
|
+
}, scene);
|
|
51
|
+
mesh.isPickable = false;
|
|
52
|
+
mesh.alwaysSelectAsActiveMesh = true;
|
|
53
|
+
mesh.renderingGroupId = 0;
|
|
54
|
+
mesh.metadata = {
|
|
55
|
+
...(mesh.metadata ?? {}),
|
|
56
|
+
editorProjectionHelper: true,
|
|
57
|
+
editorGrid: true,
|
|
58
|
+
};
|
|
59
|
+
return { mesh, direction, offsetIndex };
|
|
60
|
+
}
|
|
61
|
+
function updateGrid(force) {
|
|
62
|
+
if (disposed || !visible)
|
|
63
|
+
return;
|
|
64
|
+
const frameState = readGridFrameState();
|
|
65
|
+
if (!force && lastFrameState && isSameGridFrameState(lastFrameState, frameState))
|
|
66
|
+
return;
|
|
67
|
+
lastFrameState = frameState;
|
|
68
|
+
currentStep = frameState.step;
|
|
69
|
+
for (const line of lines) {
|
|
70
|
+
updateGridLine(line, frameState);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function readGridFrameState() {
|
|
74
|
+
const step = resolveAdaptiveStep(scene, options.camera ?? null, adaptiveSteps, targetScreenSpacingPx);
|
|
75
|
+
const majorStep = normalizePositive(options.majorStep, step * DEFAULT_MAJOR_STEP_MULTIPLIER);
|
|
76
|
+
return {
|
|
77
|
+
center: readGridCenter(scene, options.camera ?? null, step),
|
|
78
|
+
step,
|
|
79
|
+
majorStep,
|
|
80
|
+
lineSpan: halfLineCount * step,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function updateGridLine(line, frameState) {
|
|
84
|
+
const offset = line.offsetIndex * frameState.step;
|
|
85
|
+
const xMin = frameState.center.x - frameState.lineSpan;
|
|
86
|
+
const xMax = frameState.center.x + frameState.lineSpan;
|
|
87
|
+
const zMin = frameState.center.z - frameState.lineSpan;
|
|
88
|
+
const zMax = frameState.center.z + frameState.lineSpan;
|
|
89
|
+
const coordinate = line.direction === 'x' ? frameState.center.z + offset : frameState.center.x + offset;
|
|
90
|
+
const points = line.direction === 'x'
|
|
91
|
+
? [new Vector3(xMin, 0, coordinate), new Vector3(xMax, 0, coordinate)]
|
|
92
|
+
: [new Vector3(coordinate, 0, zMin), new Vector3(coordinate, 0, zMax)];
|
|
93
|
+
MeshBuilder.CreateLines(line.mesh.name, {
|
|
94
|
+
points,
|
|
95
|
+
instance: line.mesh,
|
|
96
|
+
}, scene);
|
|
97
|
+
line.mesh.color = resolveLineColor(line.direction, coordinate, frameState.step, frameState.majorStep);
|
|
98
|
+
}
|
|
99
|
+
function resolveLineColor(direction, coordinate, step, majorStep) {
|
|
100
|
+
const axisThreshold = step * 0.25;
|
|
101
|
+
if (Math.abs(coordinate) <= axisThreshold)
|
|
102
|
+
return direction === 'x' ? axisXColor : axisZColor;
|
|
103
|
+
const majorIndex = Math.round(coordinate / majorStep);
|
|
104
|
+
if (Math.abs(coordinate - majorIndex * majorStep) <= step * 0.1)
|
|
105
|
+
return majorGridColor;
|
|
106
|
+
return gridColor;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
setVisible(nextVisible) {
|
|
110
|
+
visible = nextVisible;
|
|
111
|
+
for (const line of lines) {
|
|
112
|
+
line.mesh.setEnabled?.(nextVisible);
|
|
113
|
+
}
|
|
114
|
+
if (nextVisible)
|
|
115
|
+
updateGrid(true);
|
|
116
|
+
},
|
|
117
|
+
isVisible() {
|
|
118
|
+
return visible;
|
|
119
|
+
},
|
|
120
|
+
getStep() {
|
|
121
|
+
return currentStep;
|
|
122
|
+
},
|
|
123
|
+
dispose() {
|
|
124
|
+
if (disposed)
|
|
125
|
+
return;
|
|
126
|
+
disposed = true;
|
|
127
|
+
if (renderObserver && scene.onBeforeRenderObservable?.remove) {
|
|
128
|
+
scene.onBeforeRenderObservable.remove(renderObserver);
|
|
129
|
+
}
|
|
130
|
+
renderObserver = null;
|
|
131
|
+
for (const line of lines) {
|
|
132
|
+
try {
|
|
133
|
+
line.mesh.dispose?.();
|
|
134
|
+
}
|
|
135
|
+
catch { }
|
|
136
|
+
}
|
|
137
|
+
lines.length = 0;
|
|
138
|
+
lastFrameState = null;
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function isSameGridFrameState(left, right) {
|
|
143
|
+
return left.step === right.step
|
|
144
|
+
&& left.majorStep === right.majorStep
|
|
145
|
+
&& left.lineSpan === right.lineSpan
|
|
146
|
+
&& left.center.x === right.center.x
|
|
147
|
+
&& left.center.z === right.center.z;
|
|
148
|
+
}
|
|
149
|
+
function readGridCenter(scene, camera, step) {
|
|
150
|
+
const activeCamera = scene?.activeCamera ?? camera;
|
|
151
|
+
const source = activeCamera?.target ?? activeCamera?.position ?? { x: 0, z: 0 };
|
|
152
|
+
return {
|
|
153
|
+
x: Math.floor((Number(source.x) || 0) / step) * step,
|
|
154
|
+
z: Math.floor((Number(source.z) || 0) / step) * step,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function normalizePositive(value, fallback) {
|
|
158
|
+
return Number.isFinite(value) && Number(value) > 0 ? Number(value) : fallback;
|
|
159
|
+
}
|
|
160
|
+
function normalizeAdaptiveSteps(steps, minStep) {
|
|
161
|
+
const source = steps?.length ? steps : DEFAULT_ADAPTIVE_STEPS;
|
|
162
|
+
const normalized = Array.from(new Set(source
|
|
163
|
+
.map(value => normalizePositive(value, 0))
|
|
164
|
+
.filter(value => value >= minStep))).sort((left, right) => left - right);
|
|
165
|
+
return normalized.length > 0 ? normalized : [minStep];
|
|
166
|
+
}
|
|
167
|
+
function resolveAdaptiveStep(scene, camera, steps, targetScreenSpacingPx) {
|
|
168
|
+
const pixelsPerWorldUnit = estimatePixelsPerWorldUnit(scene, camera);
|
|
169
|
+
if (!Number.isFinite(pixelsPerWorldUnit) || pixelsPerWorldUnit <= 0)
|
|
170
|
+
return steps[0] ?? DEFAULT_STEP;
|
|
171
|
+
let bestStep = steps[0] ?? DEFAULT_STEP;
|
|
172
|
+
let bestScore = Number.POSITIVE_INFINITY;
|
|
173
|
+
for (const step of steps) {
|
|
174
|
+
const screenSpacing = step * pixelsPerWorldUnit;
|
|
175
|
+
const score = Math.abs(Math.log(Math.max(screenSpacing, 0.0001) / targetScreenSpacingPx));
|
|
176
|
+
if (score < bestScore) {
|
|
177
|
+
bestScore = score;
|
|
178
|
+
bestStep = step;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return bestStep;
|
|
182
|
+
}
|
|
183
|
+
function estimatePixelsPerWorldUnit(scene, camera) {
|
|
184
|
+
const activeCamera = scene?.activeCamera ?? camera;
|
|
185
|
+
const engine = scene?.getEngine?.();
|
|
186
|
+
const viewportHeight = readViewportHeight(engine);
|
|
187
|
+
if (!activeCamera || viewportHeight <= 0)
|
|
188
|
+
return 1;
|
|
189
|
+
const orthoTop = Number(activeCamera.orthoTop);
|
|
190
|
+
const orthoBottom = Number(activeCamera.orthoBottom);
|
|
191
|
+
if (Number.isFinite(orthoTop) && Number.isFinite(orthoBottom) && orthoTop !== orthoBottom) {
|
|
192
|
+
return viewportHeight / Math.abs(orthoTop - orthoBottom);
|
|
193
|
+
}
|
|
194
|
+
const distance = estimateCameraDistanceToTarget(activeCamera);
|
|
195
|
+
const fov = normalizePositive(Number(activeCamera.fov), Math.PI / 4);
|
|
196
|
+
const visibleHeight = 2 * distance * Math.tan(fov / 2);
|
|
197
|
+
return visibleHeight > 0 ? viewportHeight / visibleHeight : 1;
|
|
198
|
+
}
|
|
199
|
+
function readViewportHeight(engine) {
|
|
200
|
+
const renderHeight = Number(engine?.getRenderHeight?.());
|
|
201
|
+
if (Number.isFinite(renderHeight) && renderHeight > 0)
|
|
202
|
+
return renderHeight;
|
|
203
|
+
const canvasHeight = Number(engine?.getRenderingCanvas?.()?.clientHeight);
|
|
204
|
+
if (Number.isFinite(canvasHeight) && canvasHeight > 0)
|
|
205
|
+
return canvasHeight;
|
|
206
|
+
return 720;
|
|
207
|
+
}
|
|
208
|
+
function estimateCameraDistanceToTarget(camera) {
|
|
209
|
+
const radius = Number(camera?.radius);
|
|
210
|
+
if (Number.isFinite(radius) && radius > 0)
|
|
211
|
+
return radius;
|
|
212
|
+
const position = camera?.position;
|
|
213
|
+
const target = camera?.target;
|
|
214
|
+
if (position && target) {
|
|
215
|
+
const distance = Math.hypot((Number(position.x) || 0) - (Number(target.x) || 0), (Number(position.y) || 0) - (Number(target.y) || 0), (Number(position.z) || 0) - (Number(target.z) || 0));
|
|
216
|
+
if (Number.isFinite(distance) && distance > 0)
|
|
217
|
+
return distance;
|
|
218
|
+
}
|
|
219
|
+
const height = Math.abs(Number(position?.y) || 0);
|
|
220
|
+
return height > 0 ? height : 8;
|
|
221
|
+
}
|
|
222
|
+
function createColor(Color3, color) {
|
|
223
|
+
return new Color3(color.r, color.g, color.b);
|
|
224
|
+
}
|
|
225
|
+
function createNoopGridController() {
|
|
226
|
+
return {
|
|
227
|
+
setVisible() { },
|
|
228
|
+
isVisible() {
|
|
229
|
+
return false;
|
|
230
|
+
},
|
|
231
|
+
getStep() {
|
|
232
|
+
return DEFAULT_STEP;
|
|
233
|
+
},
|
|
234
|
+
dispose() { },
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=infinite-grid.js.map
|