Progress
This commit is contained in:
parent
dd49f1f4f1
commit
5a34b929d8
|
@ -0,0 +1,4 @@
|
||||||
|
portals to other scenes
|
||||||
|
collision events
|
||||||
|
touch events/interactions
|
||||||
|
motion with xr without a controller
|
|
@ -2,7 +2,9 @@ version 1 .
|
||||||
|
|
||||||
Sprite = <sprite @name string @shape Shape> .
|
Sprite = <sprite @name string @shape Shape> .
|
||||||
|
|
||||||
Shape = Sphere / Box / Light / Ground / Scale / Move / Rotate / @many [Shape ...] / Texture / Color / Name / Floor / Nonphysical .
|
Shape = Mesh / Light / Scale / Move / Rotate / @many [Shape ...] / Texture / Color / Name / Floor / Nonphysical / CSG .
|
||||||
|
|
||||||
|
Mesh = Sphere / Box / Ground .
|
||||||
|
|
||||||
Sphere = <sphere> .
|
Sphere = <sphere> .
|
||||||
Box = <box> .
|
Box = <box> .
|
||||||
|
@ -33,3 +35,13 @@ Name = <name @base string @shape Shape> .
|
||||||
Floor = <floor @shape Shape> .
|
Floor = <floor @shape Shape> .
|
||||||
|
|
||||||
Nonphysical = <nonphysical @shape Shape> .
|
Nonphysical = <nonphysical @shape Shape> .
|
||||||
|
|
||||||
|
CSG = <csg @expr CSGExpr> .
|
||||||
|
|
||||||
|
CSGExpr =
|
||||||
|
/ <mesh @shape Shape>
|
||||||
|
/ <subtract @base CSGExpr @more [CSGExpr ...]>
|
||||||
|
/ <union @shapes [CSGExpr ...]>
|
||||||
|
/ <intersect @shapes [CSGExpr ...]>
|
||||||
|
/ <invert @shape CSGExpr>
|
||||||
|
.
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
<sprite "ground"
|
<sprite "ground"
|
||||||
<texture
|
<texture
|
||||||
"textures/grass-256x256.jpg"
|
"textures/grass-256x256.jpg"
|
||||||
<v 0.1 0.1>
|
<v 0.01 0.01>
|
||||||
<v 0.0 0.0>
|
<v 0.0 0.0>
|
||||||
<floor <ground <v 30.0 30.0>>>>>
|
<floor <ground <v 300.0 300.0>>>>>
|
||||||
|
|
||||||
<sprite "box"
|
<sprite "box"
|
||||||
<move <v 6.0 2.5 8.0>
|
<move <v -6.0 1.0 8.0>
|
||||||
<scale <v 10.0 0.1 10.0>
|
<scale <v 10.0 0.1 10.0>
|
||||||
<texture "textures/oak-herringbone-5e80fb40b00c9-1200.jpg"
|
<texture "textures/oak-herringbone-5e80fb40b00c9-1200.jpg"
|
||||||
<v 0.1 0.1>
|
<v 0.1 0.1>
|
||||||
|
@ -17,8 +17,34 @@
|
||||||
<floor <box>>>>>>
|
<floor <box>>>>>>
|
||||||
|
|
||||||
<sprite "box2"
|
<sprite "box2"
|
||||||
<move <v -1.0 0.5 3.0>
|
<move <v -500.0 0.5 3.0>
|
||||||
<floor
|
<floor
|
||||||
<color 1.0 0.0 0.0 0.5 <box>>>>>
|
<color 0.0 0.0 1.0 1.0
|
||||||
|
<scale <v 1000.0 1.0 1.0> <box>>>>>>
|
||||||
|
|
||||||
|
<sprite "steps"
|
||||||
|
<color 0.0 0.5 0.0
|
||||||
|
<move <v 0.0 0.0 3.5>
|
||||||
|
<scale <v 1.0 1.0 3.0>
|
||||||
|
<texture "textures/oak-herringbone-5e80fb40b00c9-1200.jpg"
|
||||||
|
[
|
||||||
|
<move <v 0.0 0.25 0.0> <box>>
|
||||||
|
<move <v 1.0 0.0 0.0> <box>>
|
||||||
|
<move <v 2.0 -0.25 0.0> <box>>
|
||||||
|
]>>>>>
|
||||||
|
|
||||||
|
<sprite "ball"
|
||||||
|
<move <v 0.0 2.0 3.0>
|
||||||
|
<scale <v 1.0 3.0 1.0>
|
||||||
|
<color 1.0 1.0 0.0
|
||||||
|
<floor
|
||||||
|
<sphere>>>>>>
|
||||||
|
|
||||||
|
<sprite "plans"
|
||||||
|
<texture "plans/signal-2022-12-27-125451_002.jpeg"
|
||||||
|
<move <v 0.0 1.0 -10.0>
|
||||||
|
<rotate <v 0.5 0.0 0.0>
|
||||||
|
<scale <v 2.0 2.0 0.1>
|
||||||
|
<box>>>>>>
|
||||||
|
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -83,6 +83,7 @@ export async function startEngine(
|
||||||
camera = new FreeCamera("camera", initialPos, scene);
|
camera = new FreeCamera("camera", initialPos, scene);
|
||||||
camera.minZ = 0.1;
|
camera.minZ = 0.1;
|
||||||
camera.rotation = initialRotation;
|
camera.rotation = initialRotation;
|
||||||
|
camera.speed = 0.5;
|
||||||
camera.attachControl(canvas, true);
|
camera.attachControl(canvas, true);
|
||||||
}
|
}
|
||||||
const sm = xrAvailable ? xr.baseExperience.sessionManager : null;
|
const sm = xrAvailable ? xr.baseExperience.sessionManager : null;
|
||||||
|
|
|
@ -77,7 +77,8 @@ function bootApp(ds: Ref, scene: Scene) {
|
||||||
field rotation: Shapes.Vector3 = Shapes.Vector3({ x:0, y:0, z:0 });
|
field rotation: Shapes.Vector3 = Shapes.Vector3({ x:0, y:0, z:0 });
|
||||||
|
|
||||||
at ds {
|
at ds {
|
||||||
on message timer.PeriodicTick(100) => {
|
const refreshPeriod = Math.floor(1000 / 30);
|
||||||
|
on message timer.PeriodicTick(refreshPeriod) => {
|
||||||
const camera = scene.cameras[0];
|
const camera = scene.cameras[0];
|
||||||
if (camera && camera instanceof TargetCamera) {
|
if (camera && camera instanceof TargetCamera) {
|
||||||
const newPosition = Shapes.Vector3(camera.position);
|
const newPosition = Shapes.Vector3(camera.position);
|
||||||
|
@ -107,7 +108,7 @@ function bootApp(ds: Ref, scene: Scene) {
|
||||||
v: Shapes.Vector3({ x: 0, y: rotation.value.y, z: 0 }),
|
v: Shapes.Vector3({ x: 0, y: rotation.value.y, z: 0 }),
|
||||||
shape: Shapes.Shape.Scale(Shapes.Scale({
|
shape: Shapes.Shape.Scale(Shapes.Scale({
|
||||||
v: Shapes.Vector3({ x: 0.4, y: 1.4, z: 0.1 }),
|
v: Shapes.Vector3({ x: 0.4, y: 1.4, z: 0.1 }),
|
||||||
shape: Shapes.Shape.Box(Shapes.Box()),
|
shape: Shapes.Shape.Mesh(Shapes.Mesh.Box(Shapes.Box())),
|
||||||
})),
|
})),
|
||||||
})),
|
})),
|
||||||
})),
|
})),
|
||||||
|
@ -115,7 +116,7 @@ function bootApp(ds: Ref, scene: Scene) {
|
||||||
v: rotation.value,
|
v: rotation.value,
|
||||||
shape: Shapes.Shape.Scale(Shapes.Scale({
|
shape: Shapes.Shape.Scale(Shapes.Scale({
|
||||||
v: Shapes.Vector3({ x:0.15, y:0.23, z:0.18 }),
|
v: Shapes.Vector3({ x:0.15, y:0.23, z:0.18 }),
|
||||||
shape: Shapes.Shape.Box(Shapes.Box()),
|
shape: Shapes.Shape.Mesh(Shapes.Mesh.Box(Shapes.Box())),
|
||||||
})),
|
})),
|
||||||
})),
|
})),
|
||||||
]),
|
]),
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import {
|
import {
|
||||||
AbstractMesh,
|
|
||||||
Color3,
|
Color3,
|
||||||
CSG,
|
CSG,
|
||||||
HemisphericLight,
|
HemisphericLight,
|
||||||
|
@ -123,16 +122,31 @@ function applyCustomizer(m: ShapeTree<Mesh>, c: MeshCustomizer) {
|
||||||
|
|
||||||
export function build(name: string, scene: Scene, shape: Shapes.Shape, customize: MeshCustomizer): ShapeTree {
|
export function build(name: string, scene: Scene, shape: Shapes.Shape, customize: MeshCustomizer): ShapeTree {
|
||||||
switch (shape._variant) {
|
switch (shape._variant) {
|
||||||
case "Sphere": {
|
case "Mesh": {
|
||||||
const t = new ShapeTree<Mesh>(scene, shape, MeshBuilder.CreateSphere(name, {}, scene));
|
const mesh = shape.value;
|
||||||
applyCustomizer(t, customize);
|
switch (mesh._variant) {
|
||||||
return t;
|
case "Sphere": {
|
||||||
}
|
const t = new ShapeTree<Mesh>(scene, shape, MeshBuilder.CreateSphere(name, {}, scene));
|
||||||
|
applyCustomizer(t, customize);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
case "Box": {
|
case "Box": {
|
||||||
const t = new ShapeTree<Mesh>(scene, shape, MeshBuilder.CreateBox(name, {}, scene));
|
const t = new ShapeTree<Mesh>(scene, shape, MeshBuilder.CreateBox(name, {}, scene));
|
||||||
applyCustomizer(t, customize);
|
applyCustomizer(t, customize);
|
||||||
return t;
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "Ground": {
|
||||||
|
const v = v2(mesh.value.size);
|
||||||
|
const t = new ShapeTree(
|
||||||
|
scene,
|
||||||
|
shape,
|
||||||
|
MeshBuilder.CreateGround(name, { width: v.x, height: v.y }, scene));
|
||||||
|
applyCustomizer(t, customize);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case "Light":
|
case "Light":
|
||||||
|
@ -141,16 +155,6 @@ export function build(name: string, scene: Scene, shape: Shapes.Shape, customize
|
||||||
shape,
|
shape,
|
||||||
new HemisphericLight(name, v3(shape.value.v), scene));
|
new HemisphericLight(name, v3(shape.value.v), scene));
|
||||||
|
|
||||||
case "Ground": {
|
|
||||||
const v = v2(shape.value.size);
|
|
||||||
const t = new ShapeTree(
|
|
||||||
scene,
|
|
||||||
shape,
|
|
||||||
MeshBuilder.CreateGround(name, { width: v.x, height: v.y }, scene));
|
|
||||||
applyCustomizer(t, customize);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "Scale": {
|
case "Scale": {
|
||||||
const t = ShapeTree.transform(name, scene, shape);
|
const t = ShapeTree.transform(name, scene, shape);
|
||||||
t.node.scaling = v3(shape.value.v);
|
t.node.scaling = v3(shape.value.v);
|
||||||
|
@ -246,6 +250,10 @@ export function build(name: string, scene: Scene, shape: Shapes.Shape, customize
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
case "CSG": {
|
||||||
|
throw new Error("unimplemented");
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
((_shape: never) => {
|
((_shape: never) => {
|
||||||
console.error('Unsupported shape variant', shape);
|
console.error('Unsupported shape variant', shape);
|
||||||
|
|
Loading…
Reference in New Issue