Skip to content

Commit f113dc1

Browse files
author
Martin Valigursky
committed
Merge branch 'main' into release-2.17
# Conflicts: # package-lock.json # package.json
2 parents de9389a + 6a6ad8d commit f113dc1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+937
-444
lines changed
154 KB
Binary file not shown.

examples/src/examples/gaussian-splatting/flipbook.example.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ assetListLoader.load(() => {
115115
player.addComponent('script');
116116
const flipbook = player.script.create(GsplatFlipbook);
117117
if (flipbook) {
118-
flipbook.fps = 30;
118+
flipbook.fps = 15;
119119
flipbook.folder = 'https://code.playcanvas.com/examples_data/example_basketball_02';
120120
flipbook.filenamePattern = '{frame:03}.compressed.ply';
121121
flipbook.startFrame = 1;

examples/src/examples/gaussian-splatting/lod-instances.controls.mjs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,32 @@
33
* @returns {JSX.Element} The returned JSX Element.
44
*/
55
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
6-
const { BindingTwoWay, LabelGroup, BooleanInput, Panel, Label } = ReactPCUI;
6+
const { BindingTwoWay, LabelGroup, BooleanInput, Panel, SliderInput, Label } = ReactPCUI;
77
return fragment(
88
jsx(
99
Panel,
1010
{ headerText: 'Settings' },
1111
jsx(
1212
LabelGroup,
13-
{ text: 'Colorize' },
13+
{ text: 'Hue Animation' },
1414
jsx(BooleanInput, {
1515
type: 'toggle',
1616
binding: new BindingTwoWay(),
1717
link: { observer, path: 'colorize' },
1818
value: observer.get('colorize')
1919
})
20+
),
21+
jsx(
22+
LabelGroup,
23+
{ text: 'Splat Budget' },
24+
jsx(SliderInput, {
25+
binding: new BindingTwoWay(),
26+
link: { observer, path: 'splatBudget' },
27+
min: 0,
28+
max: 10,
29+
precision: 1,
30+
step: 0.1
31+
})
2032
)
2133
),
2234
jsx(

examples/src/examples/gaussian-splatting/lod-instances.example.mjs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,10 @@ assetListLoader.load(() => {
210210
// allow rendering with lower LOD quality when optimal is not yet loaded
211211
app.scene.gsplat.lodUnderfillLimit = 10;
212212

213-
// internal LOD preset based on platform (7 LOD levels: 0-6)
214-
const isMobile = pc.platform.mobile;
215-
app.scene.gsplat.splatBudget = isMobile ? 1000000 : 3000000;
213+
data.set('splatBudget', pc.platform.mobile ? 1 : 3);
216214

217215
// create grid of instances centered around origin on XZ plane
218216
const half = (GRID_SIZE - 1) * 0.5;
219-
/**
220-
* Compute per-LOD distances from a base value.
221-
* @param {number} base - The base distance in world units.
222-
* @returns {number[]} The array of distances for LODs 0..6.
223-
*/
224-
const lodBase = 1.2;
225-
const lodDistances = [lodBase, lodBase * 2, lodBase * 3, lodBase * 4, lodBase * 5, lodBase * 6, lodBase * 7];
226217

227218
// Create a grid of playbot instances using unified gsplat component
228219
let componentIndex = 0;
@@ -239,13 +230,21 @@ assetListLoader.load(() => {
239230
entity.setLocalEulerAngles(180, 0, 0);
240231
app.root.addChild(entity);
241232
const gs = /** @type {any} */ (entity.gsplat);
242-
gs.lodDistances = lodDistances;
233+
gs.lodBaseDistance = 1.2;
243234
gs.setParameter('uComponentId', componentIndex);
244235
gs.setWorkBufferModifier(workBufferModifier);
245236
componentIndex++;
246237
}
247238
}
248239

240+
const applySplatBudget = () => {
241+
const millions = data.get('splatBudget');
242+
app.scene.gsplat.splatBudget = Math.round(millions * 1000000);
243+
};
244+
245+
applySplatBudget();
246+
data.on('splatBudget:set', applySplatBudget);
247+
249248
// Create a camera with fly controls
250249
const camera = new pc.Entity('camera');
251250
camera.addComponent('camera', {

examples/src/examples/gaussian-splatting/lod-streaming-sh.controls.mjs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @returns {JSX.Element} The returned JSX Element.
44
*/
55
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
6-
const { BindingTwoWay, LabelGroup, BooleanInput, Panel, SelectInput, Label } = ReactPCUI;
6+
const { BindingTwoWay, LabelGroup, BooleanInput, Panel, SelectInput, SliderInput, Label } = ReactPCUI;
77
return fragment(
88
jsx(
99
Panel,
@@ -43,6 +43,40 @@ export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
4343
{ v: 'mobile', t: 'Mobile (2-5)' }
4444
]
4545
})
46+
),
47+
jsx(
48+
LabelGroup,
49+
{ text: 'LOD Base Dist' },
50+
jsx(SliderInput, {
51+
binding: new BindingTwoWay(),
52+
link: { observer, path: 'lodBaseDistance' },
53+
min: 1,
54+
max: 50,
55+
precision: 1
56+
})
57+
),
58+
jsx(
59+
LabelGroup,
60+
{ text: 'LOD Multiplier' },
61+
jsx(SliderInput, {
62+
binding: new BindingTwoWay(),
63+
link: { observer, path: 'lodMultiplier' },
64+
min: 1.2,
65+
max: 10,
66+
precision: 1
67+
})
68+
),
69+
jsx(
70+
LabelGroup,
71+
{ text: 'Splat Budget' },
72+
jsx(SliderInput, {
73+
binding: new BindingTwoWay(),
74+
link: { observer, path: 'splatBudget' },
75+
min: 0,
76+
max: 10,
77+
precision: 1,
78+
step: 0.1
79+
})
4680
)
4781
),
4882
jsx(

examples/src/examples/gaussian-splatting/lod-streaming-sh.example.mjs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,23 @@ const config = {
6363
};
6464

6565
// LOD preset definitions with customizable distances
66-
/** @type {Record<string, { range: number[], lodDistances: number[] }>} */
66+
/** @type {Record<string, { range: number[], lodBaseDistance: number }>} */
6767
const LOD_PRESETS = {
6868
'desktop-max': {
6969
range: [0, 5],
70-
lodDistances: [15, 30, 80, 250, 300]
70+
lodBaseDistance: 15
7171
},
7272
'desktop': {
7373
range: [0, 2],
74-
lodDistances: [15, 30, 80, 250, 300]
74+
lodBaseDistance: 15
7575
},
7676
'mobile-max': {
7777
range: [1, 2],
78-
lodDistances: [15, 30, 80, 250, 300]
78+
lodBaseDistance: 15
7979
},
8080
'mobile': {
8181
range: [2, 5],
82-
lodDistances: [15, 30, 80, 250, 300]
82+
lodBaseDistance: 15
8383
}
8484
};
8585

@@ -119,6 +119,7 @@ assetListLoader.load(() => {
119119
data.set('debugLod', false);
120120
data.set('colorizeSH', false);
121121
data.set('lodPreset', pc.platform.mobile ? 'mobile' : 'desktop');
122+
data.set('splatBudget', pc.platform.mobile ? 1 : 3);
122123

123124
app.scene.gsplat.colorizeLod = !!data.get('debugLod');
124125
app.scene.gsplat.colorizeColorUpdate = !!data.get('colorizeSH');
@@ -148,12 +149,31 @@ assetListLoader.load(() => {
148149
const presetData = LOD_PRESETS[preset] || LOD_PRESETS.desktop;
149150
app.scene.gsplat.lodRangeMin = presetData.range[0];
150151
app.scene.gsplat.lodRangeMax = presetData.range[1];
151-
gs.lodDistances = presetData.lodDistances;
152+
gs.lodBaseDistance = presetData.lodBaseDistance;
153+
data.set('lodBaseDistance', presetData.lodBaseDistance);
152154
};
153155

154156
applyPreset();
155157
data.on('lodPreset:set', applyPreset);
156158

159+
data.set('lodMultiplier', 4);
160+
gs.lodMultiplier = 4;
161+
162+
data.on('lodBaseDistance:set', () => {
163+
gs.lodBaseDistance = data.get('lodBaseDistance');
164+
});
165+
data.on('lodMultiplier:set', () => {
166+
gs.lodMultiplier = data.get('lodMultiplier');
167+
});
168+
169+
const applySplatBudget = () => {
170+
const millions = data.get('splatBudget');
171+
app.scene.gsplat.splatBudget = Math.round(millions * 1000000);
172+
};
173+
174+
applySplatBudget();
175+
data.on('splatBudget:set', applySplatBudget);
176+
157177
// Create a camera with fly controls
158178
const camera = new pc.Entity('camera');
159179
camera.addComponent('camera', {

examples/src/examples/gaussian-splatting/lod-streaming.controls.mjs

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,34 @@
33
* @returns {JSX.Element} The returned JSX Element.
44
*/
55
export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
6-
const { BindingTwoWay, LabelGroup, BooleanInput, Panel, SelectInput, Label } = ReactPCUI;
6+
const { BindingTwoWay, LabelGroup, BooleanInput, Panel, SelectInput, SliderInput, Label } = ReactPCUI;
77
const isWebGPU = observer.get('isWebGPU');
88
return fragment(
9+
jsx(
10+
Panel,
11+
{ headerText: 'Camera' },
12+
jsx(
13+
LabelGroup,
14+
{ text: 'FOV' },
15+
jsx(SliderInput, {
16+
binding: new BindingTwoWay(),
17+
link: { observer, path: 'cameraFov' },
18+
min: 10,
19+
max: 120,
20+
precision: 0
21+
})
22+
),
23+
jsx(
24+
LabelGroup,
25+
{ text: 'High Res' },
26+
jsx(BooleanInput, {
27+
type: 'toggle',
28+
binding: new BindingTwoWay(),
29+
link: { observer, path: 'highRes' },
30+
value: observer.get('highRes') || false
31+
})
32+
)
33+
),
934
jsx(
1035
Panel,
1136
{ headerText: 'Settings' },
@@ -29,16 +54,6 @@ export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
2954
value: observer.get('culling') || false
3055
})
3156
),
32-
jsx(
33-
LabelGroup,
34-
{ text: 'High Res' },
35-
jsx(BooleanInput, {
36-
type: 'toggle',
37-
binding: new BindingTwoWay(),
38-
link: { observer, path: 'highRes' },
39-
value: observer.get('highRes') || false
40-
})
41-
),
4257
jsx(
4358
LabelGroup,
4459
{ text: 'Compact' },
@@ -75,27 +90,38 @@ export const controls = ({ observer, ReactPCUI, React, jsx, fragment }) => {
7590
]
7691
})
7792
),
93+
jsx(
94+
LabelGroup,
95+
{ text: 'LOD Base Dist' },
96+
jsx(SliderInput, {
97+
binding: new BindingTwoWay(),
98+
link: { observer, path: 'lodBaseDistance' },
99+
min: 1,
100+
max: 50,
101+
precision: 1
102+
})
103+
),
104+
jsx(
105+
LabelGroup,
106+
{ text: 'LOD Multiplier' },
107+
jsx(SliderInput, {
108+
binding: new BindingTwoWay(),
109+
link: { observer, path: 'lodMultiplier' },
110+
min: 1.2,
111+
max: 5,
112+
precision: 1
113+
})
114+
),
78115
jsx(
79116
LabelGroup,
80117
{ text: 'Splat Budget' },
81-
jsx(SelectInput, {
82-
type: 'string',
118+
jsx(SliderInput, {
83119
binding: new BindingTwoWay(),
84120
link: { observer, path: 'splatBudget' },
85-
value: observer.get('splatBudget') || '4M',
86-
options: [
87-
{ v: 'none', t: 'No limit' },
88-
{ v: '1M', t: '1M' },
89-
{ v: '2M', t: '2M' },
90-
{ v: '3M', t: '3M' },
91-
{ v: '4M', t: '4M' },
92-
{ v: '5M', t: '5M' },
93-
{ v: '6M', t: '6M' },
94-
{ v: '7M', t: '7M' },
95-
{ v: '8M', t: '8M' },
96-
{ v: '9M', t: '9M' },
97-
{ v: '10M', t: '10M' }
98-
]
121+
min: 0,
122+
max: 10,
123+
precision: 1,
124+
step: 0.1
99125
})
100126
)
101127
),

0 commit comments

Comments
 (0)