physics test2
This commit is contained in:
Generated
+14
-17
@@ -28,7 +28,7 @@
|
|||||||
"three-viewport-gizmo": "^2.2.0",
|
"three-viewport-gizmo": "^2.2.0",
|
||||||
"uuid": "^11.0.2",
|
"uuid": "^11.0.2",
|
||||||
"vue": "^3.5.13",
|
"vue": "^3.5.13",
|
||||||
"vuetify": "^3.7.16"
|
"vuetify": "^3.10.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@dimforge/rapier3d": "^0.18.2",
|
"@dimforge/rapier3d": "^0.18.2",
|
||||||
@@ -2070,9 +2070,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@vuetify/loader-shared": {
|
"node_modules/@vuetify/loader-shared": {
|
||||||
"version": "2.0.3",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@vuetify/loader-shared/-/loader-shared-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@vuetify/loader-shared/-/loader-shared-2.1.1.tgz",
|
||||||
"integrity": "sha512-Ss3GC7eJYkp2SF6xVzsT7FAruEmdihmn4OCk2+UocREerlXKWgOKKzTN5PN3ZVN5q05jHHrsNhTuWbhN61Bpdg==",
|
"integrity": "sha512-jSZTzTYaoiv8iwonFCVZQ0YYX/M+Uyl4ng+C4egMJT0Hcmh9gIxJL89qfZICDeo3g0IhqrvipW2FFKKRDMtVcA==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -8000,13 +8000,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vite-plugin-vuetify": {
|
"node_modules/vite-plugin-vuetify": {
|
||||||
"version": "2.0.4",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/vite-plugin-vuetify/-/vite-plugin-vuetify-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/vite-plugin-vuetify/-/vite-plugin-vuetify-2.1.2.tgz",
|
||||||
"integrity": "sha512-A4cliYUoP/u4AWSRVRvAPKgpgR987Pss7LpFa7s1GvOe8WjgDq92Rt3eVXrvgxGCWvZsPKziVqfHHdCMqeDhfw==",
|
"integrity": "sha512-I/wd6QS+DO6lHmuGoi1UTyvvBTQ2KDzQZ9oowJQEJ6OcjWfJnscYXx2ptm6S7fJSASuZT8jGRBL3LV4oS3LpaA==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vuetify/loader-shared": "^2.0.3",
|
"@vuetify/loader-shared": "^2.1.1",
|
||||||
"debug": "^4.3.3",
|
"debug": "^4.3.3",
|
||||||
"upath": "^2.0.1"
|
"upath": "^2.0.1"
|
||||||
},
|
},
|
||||||
@@ -8198,22 +8198,19 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vuetify": {
|
"node_modules/vuetify": {
|
||||||
"version": "3.7.16",
|
"version": "3.10.5",
|
||||||
"resolved": "https://registry.npmjs.org/vuetify/-/vuetify-3.7.16.tgz",
|
"resolved": "https://registry.npmjs.org/vuetify/-/vuetify-3.10.5.tgz",
|
||||||
"integrity": "sha512-Few/cBtgJYgdkzi0LWmVy67G5uc2+q7oWcadbcTUPAtEtGYNh2AM28h01Fk+ScJgfxkA077//ZDff1rh3jYG/w==",
|
"integrity": "sha512-3h1onfjcj04B+LJ0cXvGrOOe6C3652JAlyUAuGKgQXwhP9Oe1hAfdM6+svXR5Dt1xC39lQEGqJdacZtwisUEoQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
|
||||||
"node": "^12.20 || >=14.13"
|
|
||||||
},
|
|
||||||
"funding": {
|
"funding": {
|
||||||
"type": "github",
|
"type": "github",
|
||||||
"url": "https://github.com/sponsors/johnleider"
|
"url": "https://github.com/sponsors/johnleider"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": ">=4.7",
|
"typescript": ">=4.7",
|
||||||
"vite-plugin-vuetify": ">=1.0.0",
|
"vite-plugin-vuetify": ">=2.1.0",
|
||||||
"vue": "^3.3.0",
|
"vue": "^3.5.0",
|
||||||
"webpack-plugin-vuetify": ">=2.0.0"
|
"webpack-plugin-vuetify": ">=3.1.0"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"typescript": {
|
"typescript": {
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@
|
|||||||
"three-viewport-gizmo": "^2.2.0",
|
"three-viewport-gizmo": "^2.2.0",
|
||||||
"uuid": "^11.0.2",
|
"uuid": "^11.0.2",
|
||||||
"vue": "^3.5.13",
|
"vue": "^3.5.13",
|
||||||
"vuetify": "^3.7.16"
|
"vuetify": "^3.10.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@dimforge/rapier3d": "^0.18.2",
|
"@dimforge/rapier3d": "^0.18.2",
|
||||||
|
|||||||
Binary file not shown.
@@ -27,14 +27,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"mesh":1,
|
"mesh":1,
|
||||||
"name":"tunnel"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mesh":2,
|
|
||||||
"name":"wall",
|
"name":"wall",
|
||||||
"rotation":[
|
"rotation":[
|
||||||
0,
|
0,
|
||||||
0.7071068286895752,
|
-0.7071068286895752,
|
||||||
0,
|
0,
|
||||||
0.7071068286895752
|
0.7071068286895752
|
||||||
],
|
],
|
||||||
@@ -45,13 +41,17 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"mesh":3,
|
"mesh":2,
|
||||||
"name":"door",
|
"name":"door",
|
||||||
"translation":[
|
"translation":[
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
-0.44999998807907104
|
-0.44999998807907104
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mesh":3,
|
||||||
|
"name":"tunnel"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"materials":[
|
"materials":[
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"Curve.003",
|
"name":"Curve.005",
|
||||||
"primitives":[
|
"primitives":[
|
||||||
{
|
{
|
||||||
"attributes":{
|
"attributes":{
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"Curve.005",
|
"name":"Curve.008",
|
||||||
"primitives":[
|
"primitives":[
|
||||||
{
|
{
|
||||||
"attributes":{
|
"attributes":{
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"Curve.008",
|
"name":"Curve.004",
|
||||||
"primitives":[
|
"primitives":[
|
||||||
{
|
{
|
||||||
"attributes":{
|
"attributes":{
|
||||||
@@ -176,73 +176,39 @@
|
|||||||
{
|
{
|
||||||
"bufferView":4,
|
"bufferView":4,
|
||||||
"componentType":5126,
|
"componentType":5126,
|
||||||
"count":12,
|
"count":4,
|
||||||
"max":[
|
"max":[
|
||||||
0.5994362831115723,
|
-0.04999993368983269,
|
||||||
0.6900395154953003,
|
0.7055734992027283,
|
||||||
0.40000441670417786
|
0.5996518731117249
|
||||||
],
|
],
|
||||||
"min":[
|
"min":[
|
||||||
-0.6005637049674988,
|
-0.05000001937150955,
|
||||||
0.010013699531555176,
|
-0.03282167762517929,
|
||||||
-0.3999955654144287
|
-0.600348174571991
|
||||||
],
|
],
|
||||||
"type":"VEC3"
|
"type":"VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView":5,
|
"bufferView":5,
|
||||||
"componentType":5126,
|
"componentType":5126,
|
||||||
"count":12,
|
"count":4,
|
||||||
"type":"VEC3"
|
"type":"VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView":6,
|
"bufferView":6,
|
||||||
"componentType":5126,
|
"componentType":5126,
|
||||||
"count":12,
|
"count":4,
|
||||||
"type":"VEC2"
|
"type":"VEC2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView":7,
|
"bufferView":7,
|
||||||
"componentType":5123,
|
"componentType":5123,
|
||||||
"count":18,
|
|
||||||
"type":"SCALAR"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView":8,
|
|
||||||
"componentType":5126,
|
|
||||||
"count":4,
|
|
||||||
"max":[
|
|
||||||
0.600348174571991,
|
|
||||||
0.7055734992027283,
|
|
||||||
-0.04999995976686478
|
|
||||||
],
|
|
||||||
"min":[
|
|
||||||
-0.5996518731117249,
|
|
||||||
-0.03282167762517929,
|
|
||||||
-0.04999999329447746
|
|
||||||
],
|
|
||||||
"type":"VEC3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView":9,
|
|
||||||
"componentType":5126,
|
|
||||||
"count":4,
|
|
||||||
"type":"VEC3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView":10,
|
|
||||||
"componentType":5126,
|
|
||||||
"count":4,
|
|
||||||
"type":"VEC2"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bufferView":11,
|
|
||||||
"componentType":5123,
|
|
||||||
"count":6,
|
"count":6,
|
||||||
"type":"SCALAR"
|
"type":"SCALAR"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView":12,
|
"bufferView":8,
|
||||||
"componentType":5126,
|
"componentType":5126,
|
||||||
"count":40,
|
"count":40,
|
||||||
"max":[
|
"max":[
|
||||||
@@ -258,22 +224,56 @@
|
|||||||
"type":"VEC3"
|
"type":"VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView":13,
|
"bufferView":9,
|
||||||
"componentType":5126,
|
"componentType":5126,
|
||||||
"count":40,
|
"count":40,
|
||||||
"type":"VEC3"
|
"type":"VEC3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView":14,
|
"bufferView":10,
|
||||||
"componentType":5126,
|
"componentType":5126,
|
||||||
"count":40,
|
"count":40,
|
||||||
"type":"VEC2"
|
"type":"VEC2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bufferView":15,
|
"bufferView":11,
|
||||||
"componentType":5123,
|
"componentType":5123,
|
||||||
"count":60,
|
"count":60,
|
||||||
"type":"SCALAR"
|
"type":"SCALAR"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView":12,
|
||||||
|
"componentType":5126,
|
||||||
|
"count":12,
|
||||||
|
"max":[
|
||||||
|
0.5994362831115723,
|
||||||
|
0.6900395154953003,
|
||||||
|
0.40000441670417786
|
||||||
|
],
|
||||||
|
"min":[
|
||||||
|
-0.6005637049674988,
|
||||||
|
0.010013699531555176,
|
||||||
|
-0.3999955654144287
|
||||||
|
],
|
||||||
|
"type":"VEC3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView":13,
|
||||||
|
"componentType":5126,
|
||||||
|
"count":12,
|
||||||
|
"type":"VEC3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView":14,
|
||||||
|
"componentType":5126,
|
||||||
|
"count":12,
|
||||||
|
"type":"VEC2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView":15,
|
||||||
|
"componentType":5123,
|
||||||
|
"count":18,
|
||||||
|
"type":"SCALAR"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bufferViews":[
|
"bufferViews":[
|
||||||
@@ -303,74 +303,74 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer":0,
|
"buffer":0,
|
||||||
"byteLength":144,
|
"byteLength":48,
|
||||||
"byteOffset":840,
|
"byteOffset":840,
|
||||||
"target":34962
|
"target":34962
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"buffer":0,
|
|
||||||
"byteLength":144,
|
|
||||||
"byteOffset":984,
|
|
||||||
"target":34962
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"buffer":0,
|
|
||||||
"byteLength":96,
|
|
||||||
"byteOffset":1128,
|
|
||||||
"target":34962
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"buffer":0,
|
|
||||||
"byteLength":36,
|
|
||||||
"byteOffset":1224,
|
|
||||||
"target":34963
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"buffer":0,
|
"buffer":0,
|
||||||
"byteLength":48,
|
"byteLength":48,
|
||||||
"byteOffset":1260,
|
"byteOffset":888,
|
||||||
"target":34962
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"buffer":0,
|
|
||||||
"byteLength":48,
|
|
||||||
"byteOffset":1308,
|
|
||||||
"target":34962
|
"target":34962
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer":0,
|
"buffer":0,
|
||||||
"byteLength":32,
|
"byteLength":32,
|
||||||
"byteOffset":1356,
|
"byteOffset":936,
|
||||||
"target":34962
|
"target":34962
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer":0,
|
"buffer":0,
|
||||||
"byteLength":12,
|
"byteLength":12,
|
||||||
"byteOffset":1388,
|
"byteOffset":968,
|
||||||
"target":34963
|
"target":34963
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer":0,
|
"buffer":0,
|
||||||
"byteLength":480,
|
"byteLength":480,
|
||||||
"byteOffset":1400,
|
"byteOffset":980,
|
||||||
"target":34962
|
"target":34962
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer":0,
|
"buffer":0,
|
||||||
"byteLength":480,
|
"byteLength":480,
|
||||||
"byteOffset":1880,
|
"byteOffset":1460,
|
||||||
"target":34962
|
"target":34962
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer":0,
|
"buffer":0,
|
||||||
"byteLength":320,
|
"byteLength":320,
|
||||||
"byteOffset":2360,
|
"byteOffset":1940,
|
||||||
"target":34962
|
"target":34962
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"buffer":0,
|
"buffer":0,
|
||||||
"byteLength":120,
|
"byteLength":120,
|
||||||
"byteOffset":2680,
|
"byteOffset":2260,
|
||||||
|
"target":34963
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer":0,
|
||||||
|
"byteLength":144,
|
||||||
|
"byteOffset":2380,
|
||||||
|
"target":34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer":0,
|
||||||
|
"byteLength":144,
|
||||||
|
"byteOffset":2524,
|
||||||
|
"target":34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer":0,
|
||||||
|
"byteLength":96,
|
||||||
|
"byteOffset":2668,
|
||||||
|
"target":34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer":0,
|
||||||
|
"byteLength":36,
|
||||||
|
"byteOffset":2764,
|
||||||
"target":34963
|
"target":34963
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -16,19 +16,19 @@
|
|||||||
</v-btn-toggle>
|
</v-btn-toggle>
|
||||||
<template v-if="currentObject?.__o">
|
<template v-if="currentObject?.__o">
|
||||||
<v-card subtitle="Position" class="ma-1" color="light-blue-darken-4">
|
<v-card subtitle="Position" class="ma-1" color="light-blue-darken-4">
|
||||||
<v-text-field type="number" hide-details density="compact" label="x" v-model="currentObject.__o.position.x"></v-text-field>
|
<v-number-input :precision="null" controlVariant="stacked" hide-details density="compact" label="x" v-model="currentObject.__o.position.x"></v-number-input>
|
||||||
<v-text-field type="number" hide-details density="compact" label="y" v-model="currentObject.__o.position.y"></v-text-field>
|
<v-number-input :precision="null" controlVariant="stacked" hide-details density="compact" label="y" v-model="currentObject.__o.position.y"></v-number-input>
|
||||||
<v-text-field type="number" hide-details density="compact" label="z" v-model="currentObject.__o.position.z"></v-text-field>
|
<v-number-input :precision="null" controlVariant="stacked" hide-details density="compact" label="z" v-model="currentObject.__o.position.z"></v-number-input>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card subtitle="Rotation" class="ma-1" color="green-darken-4">
|
<v-card subtitle="Rotation" class="ma-1" color="green-darken-4">
|
||||||
<v-text-field type="number" hide-details density="compact" label="x" v-model="currentObject.__o.rotation.x"></v-text-field>
|
<v-number-input :precision="null" controlVariant="stacked" hide-details density="compact" label="x" v-model="currentObject.__o.rotation.x"></v-number-input>
|
||||||
<v-text-field type="number" hide-details density="compact" label="y" v-model="currentObject.__o.rotation.y"></v-text-field>
|
<v-number-input :precision="null" controlVariant="stacked" hide-details density="compact" label="y" v-model="currentObject.__o.rotation.y"></v-number-input>
|
||||||
<v-text-field type="number" hide-details density="compact" label="z" v-model="currentObject.__o.rotation.z"></v-text-field>
|
<v-number-input :precision="null" controlVariant="stacked" hide-details density="compact" label="z" v-model="currentObject.__o.rotation.z"></v-number-input>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card subtitle="Scale" class="ma-1" color="pink-darken-4">
|
<v-card subtitle="Scale" class="ma-1" color="pink-darken-4">
|
||||||
<v-text-field type="number" hide-details density="compact" label="x" v-model="currentObject.__o.scale.x"></v-text-field>
|
<v-number-input :precision="null" controlVariant="stacked" hide-details density="compact" label="x" v-model="currentObject.__o.scale.x"></v-number-input>
|
||||||
<v-text-field type="number" hide-details density="compact" label="y" v-model="currentObject.__o.scale.y"></v-text-field>
|
<v-number-input :precision="null" controlVariant="stacked" hide-details density="compact" label="y" v-model="currentObject.__o.scale.y"></v-number-input>
|
||||||
<v-text-field type="number" hide-details density="compact" label="z" v-model="currentObject.__o.scale.z"></v-text-field>
|
<v-number-input :precision="null" controlVariant="stacked" hide-details density="compact" label="z" v-model="currentObject.__o.scale.z"></v-number-input>
|
||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
</v-navigation-drawer>
|
</v-navigation-drawer>
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ export default {
|
|||||||
])
|
])
|
||||||
maze.load().then(o=>{
|
maze.load().then(o=>{
|
||||||
gameEngine.activeObjects.add(o);
|
gameEngine.activeObjects.add(o);
|
||||||
o.scale.set(5,5,5);
|
//o.scale.set(5,5,5);
|
||||||
})
|
})
|
||||||
|
|
||||||
new Grass(Grass.positions(1000,50,50), '/static/textures/grass01.png', 1, .5).then(mesh=>{
|
new Grass(Grass.positions(1000,50,50), '/static/textures/grass01.png', 1, .5).then(mesh=>{
|
||||||
|
|||||||
@@ -5,12 +5,15 @@ import { TextObject } from '../TextObject';
|
|||||||
class MazeObject {
|
class MazeObject {
|
||||||
constructor(engine, def, params = {}){
|
constructor(engine, def, params = {}){
|
||||||
let room = new Group();
|
let room = new Group();
|
||||||
let scene = room;
|
let root = room;
|
||||||
this.object = room;
|
this.object = room;
|
||||||
let context = {};
|
let context = {};
|
||||||
context.wallSize = params.wallSize || .65;
|
|
||||||
context.tubeSize = params.tubeSize || .8;
|
const scale = 5;
|
||||||
context.wallDepth = params.wallDepth || .1;
|
|
||||||
|
context.wallSize = params.wallSize || .65*scale;
|
||||||
|
context.tubeSize = params.tubeSize || .8*scale;
|
||||||
|
context.wallDepth = params.wallDepth || .1*scale;
|
||||||
context.fontPath = params.fontPath || '/static/fonts/ZapfChanceryC.otf';
|
context.fontPath = params.fontPath || '/static/fonts/ZapfChanceryC.otf';
|
||||||
|
|
||||||
const cameraNear = .2;
|
const cameraNear = .2;
|
||||||
@@ -33,22 +36,21 @@ class MazeObject {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let o = {};
|
let o = {};
|
||||||
let mazeGeometries = [], areas = [];
|
let areas = [], mazeMeshes = [];
|
||||||
|
|
||||||
this.mazeObject = function(def, room, step = 0) {
|
this.mazeObject = function(def, room, step = 0) {
|
||||||
let offsetZ = 0, e;
|
let offsetZ = 0, e;
|
||||||
def.len = def.len || 0;
|
def.len = def.len || 0;
|
||||||
if (step == 0) {
|
if (step == 0) {
|
||||||
e = o.door.geometry.clone();
|
e = o.door.clone();
|
||||||
e.rotateY(_tf.rotation.f);
|
e.rotateY(_tf.rotation.f);
|
||||||
mazeGeometries.push(e);
|
mazeMeshes.push(e);
|
||||||
}
|
}
|
||||||
for (let i = 0; i < def.len; i++) {
|
for (let i = 0; i < def.len; i++) {
|
||||||
let t = o.tunnel.geometry.clone();
|
let t = o.tunnel.clone();
|
||||||
t.translate(0, 0, i * context.tubeSize + context.wallDepth / 2);
|
t.position.set(0, 0, i * context.tubeSize + context.wallDepth / 2);
|
||||||
def.matrix && t.applyMatrix4(def.matrix);
|
def.matrix && t.applyMatrix4(def.matrix);
|
||||||
|
mazeMeshes.push(t);
|
||||||
mazeGeometries.push(t);
|
|
||||||
}
|
}
|
||||||
offsetZ = context.wallDepth + def.len * context.tubeSize - context.tubeSize / 2;
|
offsetZ = context.wallDepth + def.len * context.tubeSize - context.tubeSize / 2;
|
||||||
if (!def.len) offsetZ = -.275;
|
if (!def.len) offsetZ = -.275;
|
||||||
@@ -58,6 +60,14 @@ class MazeObject {
|
|||||||
room.localToWorld(new Vector3(context.tubeSize / 2 - cameraNear, 0, offsetZ + cameraNear))
|
room.localToWorld(new Vector3(context.tubeSize / 2 - cameraNear, 0, offsetZ + cameraNear))
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
engine.phy.add(
|
||||||
|
{position: room.localToWorld(new Vector3(context.tubeSize / 2 - cameraNear, 0, offsetZ + cameraNear))},
|
||||||
|
'fixed', false, undefined, 'cuboid',{
|
||||||
|
width:offsetZ*10, height:10, depth:10
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
if (def.type == 'area') {
|
if (def.type == 'area') {
|
||||||
def.area.forEach(ar => {
|
def.area.forEach(ar => {
|
||||||
areas.push({
|
areas.push({
|
||||||
@@ -75,23 +85,23 @@ class MazeObject {
|
|||||||
// def.matrix && e.applyMatrix4(def.matrix);
|
// def.matrix && e.applyMatrix4(def.matrix);
|
||||||
// mazeGeometries.push(e);
|
// mazeGeometries.push(e);
|
||||||
} else {
|
} else {
|
||||||
e = [o.floor.geometry.clone(), o.door.geometry.clone(), o[def.r ? 'door' : 'wall'].geometry.clone(),
|
e = [o.floor.clone(), o.door.clone(), o[def.r ? 'door' : 'wall'].clone(),
|
||||||
o[def.f ? 'door' : 'wall'].geometry.clone(), o[def.l ? 'door' : 'wall'].geometry.clone()];
|
o[def.f ? 'door' : 'wall'].clone(), o[def.l ? 'door' : 'wall'].clone()];
|
||||||
e[0].translate(0, 0, offsetZ + context.wallSize);
|
e[0].position.set(0, 0, offsetZ + context.wallSize);
|
||||||
|
|
||||||
e[1].rotateY(_tf.rotation.b);
|
e[1].rotateY(_tf.rotation.b);
|
||||||
e[2].rotateY(_tf.rotation.r);
|
e[2].rotateY(_tf.rotation.r);
|
||||||
e[3].rotateY(_tf.rotation.f);
|
e[3].rotateY(_tf.rotation.f);
|
||||||
e[4].rotateY(_tf.rotation.l);
|
e[4].rotateY(_tf.rotation.l);
|
||||||
|
|
||||||
e[1].translate(0, 0, offsetZ + 0);
|
e[1].position.set(0, 0, offsetZ + 0);
|
||||||
e[2].translate(-context.wallSize, 0, offsetZ + context.wallSize);
|
e[2].position.set(-context.wallSize, 0, offsetZ + context.wallSize);
|
||||||
e[3].translate(0, 0, offsetZ + context.wallSize * 2);
|
e[3].position.set(0, 0, offsetZ + context.wallSize * 2);
|
||||||
e[4].translate(context.wallSize, 0, offsetZ + context.wallSize);
|
e[4].position.set(context.wallSize, 0, offsetZ + context.wallSize);
|
||||||
|
|
||||||
e.forEach(g => {
|
e.forEach(g => {
|
||||||
def.matrix && g.applyMatrix4(def.matrix);
|
def.matrix && g.applyMatrix4(def.matrix);
|
||||||
mazeGeometries.push(g);
|
mazeMeshes.push(g);
|
||||||
});
|
});
|
||||||
areas.push({
|
areas.push({
|
||||||
a: [
|
a: [
|
||||||
@@ -119,7 +129,7 @@ class MazeObject {
|
|||||||
mtx.makeRotationY(_tf.rotation[d]);
|
mtx.makeRotationY(_tf.rotation[d]);
|
||||||
mtx.setPosition(_tf.pNext[d][0], 0, _tf.pNext[d][1] + offsetZ);
|
mtx.setPosition(_tf.pNext[d][0], 0, _tf.pNext[d][1] + offsetZ);
|
||||||
let rr = new Group();
|
let rr = new Group();
|
||||||
scene.add(rr);
|
root.add(rr);
|
||||||
def[d].matrix = mtx.premultiply(def.matrix || new Matrix4());
|
def[d].matrix = mtx.premultiply(def.matrix || new Matrix4());
|
||||||
rr.applyMatrix4(def[d].matrix);
|
rr.applyMatrix4(def[d].matrix);
|
||||||
rr.updateMatrixWorld();
|
rr.updateMatrixWorld();
|
||||||
@@ -132,14 +142,18 @@ class MazeObject {
|
|||||||
['tunnel', 'wall', 'door', 'floor'].forEach(e => {
|
['tunnel', 'wall', 'door', 'floor'].forEach(e => {
|
||||||
o[e] = mazeAsset.scene.getObjectByName(e);
|
o[e] = mazeAsset.scene.getObjectByName(e);
|
||||||
o[e].frustumCulled = false;
|
o[e].frustumCulled = false;
|
||||||
|
o[e].scale.set(scale, scale, scale)
|
||||||
});
|
});
|
||||||
o.tunnel.material.depthWrite = false
|
|
||||||
this.mazeObject(def, room);
|
this.mazeObject(def, room);
|
||||||
mazeGeometries.forEach(mg=>{
|
mazeMeshes.forEach(mesh=>{
|
||||||
scene.add(new Mesh(mg, o.tunnel.material));
|
//let mesh = new Mesh(mg, o.tunnel.material)
|
||||||
|
root.add(mesh);
|
||||||
|
engine.phy.add(mesh, 'dynamic')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log(o.tunnel)
|
||||||
//scene.add(new Mesh(BufferGeometryUtils.mergeGeometries(mazeGeometries, false), o.tunnel.material));
|
//scene.add(new Mesh(BufferGeometryUtils.mergeGeometries(mazeGeometries, false), o.tunnel.material));
|
||||||
console.log(room);
|
//console.log(room);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class MazeQuizGame {
|
|||||||
len,
|
len,
|
||||||
objects:[
|
objects:[
|
||||||
{
|
{
|
||||||
type: 'text', text: cq.s, position:[0,.4,len], rotation:[0,Math.PI, 0]
|
type: 'text', text: cq.s, position:[0,.44,len-0.2], rotation:[0,Math.PI, 0]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[lrv?'r':'l']:{
|
[lrv?'r':'l']:{
|
||||||
@@ -32,7 +32,7 @@ class MazeQuizGame {
|
|||||||
len: lr,
|
len: lr,
|
||||||
objects:[
|
objects:[
|
||||||
{
|
{
|
||||||
type: 'text', text: cq.h, position:[0,.4,lr], rotation:[0,Math.PI, 0]
|
type: 'text', text: cq.h, position:[0,.44,lr-0.2], rotation:[0,Math.PI, 0]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,8 @@ class Clickable {
|
|||||||
raycaster.setFromCamera(mouse, camera);
|
raycaster.setFromCamera(mouse, camera);
|
||||||
let forExecute = [];
|
let forExecute = [];
|
||||||
objects.forEach(o => {
|
objects.forEach(o => {
|
||||||
console.log(1)
|
|
||||||
o.getWorldPosition(v);
|
o.getWorldPosition(v);
|
||||||
if (camera.position.distanceTo(v) <= o._clickable.distance && o.visible) {
|
if (camera.position.distanceTo(v) <= o._clickable.distance && o.visible) {
|
||||||
console.log(2)
|
|
||||||
const intersects = raycaster.intersectObject(o);
|
const intersects = raycaster.intersectObject(o);
|
||||||
// intersects.forEach(i=>{
|
// intersects.forEach(i=>{
|
||||||
// forExecute.push({o, i})
|
// forExecute.push({o, i})
|
||||||
|
|||||||
+13
-11
@@ -63,22 +63,24 @@ class Hero{
|
|||||||
// //colliderBody.sleepSpeedLimit = 1.0;
|
// //colliderBody.sleepSpeedLimit = 1.0;
|
||||||
// gameEngine.phy.world.addBody(colliderBody)
|
// gameEngine.phy.world.addBody(colliderBody)
|
||||||
|
|
||||||
let bodyDesc = RAPIER.RigidBodyDesc.kinematicPositionBased().setTranslation(
|
let po = gameEngine.phy.add(this.model, 'kinematicPositionBased', false, undefined, 'ball', { radius: 0.28})
|
||||||
// characterCollider.position.x,
|
|
||||||
// characterCollider.position.y,
|
// let bodyDesc = RAPIER.RigidBodyDesc.kinematicPositionBased().setTranslation(
|
||||||
// characterCollider.position.z
|
// // characterCollider.position.x,
|
||||||
-1, 3, 1
|
// // characterCollider.position.y,
|
||||||
)
|
// // characterCollider.position.z
|
||||||
let rigidBody = gameEngine.phy.world.createRigidBody(bodyDesc);
|
// -1, 3, 1
|
||||||
let dynamicCollider = RAPIER.ColliderDesc.ball(0.28);
|
// )
|
||||||
gameEngine.phy.world.createCollider(dynamicCollider, rigidBody.handle);
|
// let rigidBody = gameEngine.phy.world.createRigidBody(bodyDesc);
|
||||||
|
// let dynamicCollider = RAPIER.ColliderDesc.ball(0.28);
|
||||||
|
// gameEngine.phy.world.createCollider(dynamicCollider, rigidBody.handle);
|
||||||
|
|
||||||
this.characterControls = new CharacterControls(this.model, this.mixer,
|
this.characterControls = new CharacterControls(this.model, this.mixer,
|
||||||
this.animationsMap, gameEngine.orbitControls, gameEngine.camera, 'idle',
|
this.animationsMap, gameEngine.orbitControls, gameEngine.camera, 'idle',
|
||||||
new RAPIER.Ray(
|
new RAPIER.Ray(
|
||||||
{ x: 0, y: 0, z: 0 },
|
{ x: 0, y: 0, z: 0 },
|
||||||
{ x: 0, y: -1, z: 0}
|
{ x: 0, y: -1, z: 0}
|
||||||
), rigidBody, this.pointerControls)
|
), po.rigidBody, this.pointerControls)
|
||||||
|
|
||||||
// this.characterCollider = characterCollider;
|
// this.characterCollider = characterCollider;
|
||||||
// this.colliderBody = colliderBody;
|
// this.colliderBody = colliderBody;
|
||||||
@@ -146,7 +148,7 @@ class Hero{
|
|||||||
this.delta += dlt;
|
this.delta += dlt;
|
||||||
if (this.delta > 0.016){
|
if (this.delta > 0.016){
|
||||||
this.characterControls.update(this.gameEngine.phy.world, this.delta, pc)
|
this.characterControls.update(this.gameEngine.phy.world, this.delta, pc)
|
||||||
this.gameEngine.phy.world.step()
|
this.gameEngine.phy.step()
|
||||||
this.delta = 0;
|
this.delta = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
import * as RAPIER from '@dimforge/rapier3d'
|
||||||
|
|
||||||
|
// export type PhysicsObject = {
|
||||||
|
// mesh: THREE.Mesh
|
||||||
|
// collider: Rapier.Collider
|
||||||
|
// rigidBody: Rapier.RigidBody
|
||||||
|
// fn?: Function
|
||||||
|
// autoAnimate: boolean
|
||||||
|
// }
|
||||||
|
|
||||||
|
class Physics{
|
||||||
|
constructor(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
init = async ()=>{
|
||||||
|
let gravity = { x: 0.0, y: -9.81, z: 0.0 };
|
||||||
|
let world = new RAPIER.World(gravity);
|
||||||
|
|
||||||
|
// Create Ground.
|
||||||
|
let bodyDesc = RAPIER.RigidBodyDesc.fixed();
|
||||||
|
let body = world.createRigidBody(bodyDesc);
|
||||||
|
let colliderDesc = RAPIER.ColliderDesc.cuboid(100.0, 0.1, 100.0);
|
||||||
|
world.createCollider(colliderDesc, body.handle);
|
||||||
|
this.world = world;
|
||||||
|
this.physicsObjects = [];
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
add = (mesh, rigidBodyType, autoAnimate = true, postPhysicsFn, colliderType, colliderSettings) => {
|
||||||
|
const rigidBodyDesc = RAPIER.RigidBodyDesc[rigidBodyType]()
|
||||||
|
rigidBodyDesc.setTranslation(mesh.position.x, mesh.position.y, mesh.position.z)
|
||||||
|
|
||||||
|
// * Responsible for collision response
|
||||||
|
const rigidBody = this.world.createRigidBody(rigidBodyDesc)
|
||||||
|
|
||||||
|
let colliderDesc
|
||||||
|
|
||||||
|
switch (colliderType) {
|
||||||
|
case 'cuboid':
|
||||||
|
{
|
||||||
|
const { width, height, depth } = colliderSettings
|
||||||
|
colliderDesc = RAPIER.ColliderDesc.cuboid(width, height, depth)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'ball':
|
||||||
|
{
|
||||||
|
const { radius } = colliderSettings
|
||||||
|
colliderDesc = RAPIER.ColliderDesc.ball(radius)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'capsule':
|
||||||
|
{
|
||||||
|
const { halfHeight, radius } = colliderSettings
|
||||||
|
colliderDesc = RAPIER.ColliderDesc.capsule(halfHeight, radius)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
colliderDesc = RAPIER.ColliderDesc.trimesh(
|
||||||
|
mesh.geometry.attributes.position.array,
|
||||||
|
mesh.geometry.index?.array
|
||||||
|
)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!colliderDesc) {
|
||||||
|
console.error('Collider Mesh Error: convex mesh creation failed.')
|
||||||
|
}
|
||||||
|
|
||||||
|
// * Responsible for collision detection
|
||||||
|
const collider = this.world.createCollider(colliderDesc, rigidBody)
|
||||||
|
|
||||||
|
const physicsObject = { mesh, collider, rigidBody, fn: postPhysicsFn, autoAnimate }
|
||||||
|
|
||||||
|
this.physicsObjects.push(physicsObject)
|
||||||
|
|
||||||
|
return physicsObject
|
||||||
|
}
|
||||||
|
|
||||||
|
step(){
|
||||||
|
this.world.step()
|
||||||
|
|
||||||
|
for (let po of this.physicsObjects) {
|
||||||
|
const autoAnimate = po.autoAnimate
|
||||||
|
|
||||||
|
if (autoAnimate) {
|
||||||
|
const mesh = po.mesh
|
||||||
|
const collider = po.collider
|
||||||
|
mesh.position.copy(collider.translation())
|
||||||
|
mesh.quaternion.copy(collider.rotation() )
|
||||||
|
}
|
||||||
|
|
||||||
|
const fn = po.fn
|
||||||
|
fn && fn()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Physics }
|
||||||
+13
-14
@@ -13,7 +13,7 @@ import { TransformControls } from 'three/addons/controls/TransformControls.js';
|
|||||||
import { ARButton } from 'three/addons/webxr/ARButton.js';
|
import { ARButton } from 'three/addons/webxr/ARButton.js';
|
||||||
import { XRButton } from 'three/addons/webxr/XRButton.js';
|
import { XRButton } from 'three/addons/webxr/XRButton.js';
|
||||||
import { XRControllerModelFactory } from 'three/addons/webxr/XRControllerModelFactory.js';
|
import { XRControllerModelFactory } from 'three/addons/webxr/XRControllerModelFactory.js';
|
||||||
import * as RAPIER from '@dimforge/rapier3d'
|
import { Physics } from './Physics.js';
|
||||||
import { Clickable } from './Clickable.js';
|
import { Clickable } from './Clickable.js';
|
||||||
|
|
||||||
class GameEngine {
|
class GameEngine {
|
||||||
@@ -161,7 +161,7 @@ class GameEngine {
|
|||||||
gameEngine.camera.updateProjectionMatrix();
|
gameEngine.camera.updateProjectionMatrix();
|
||||||
})
|
})
|
||||||
|
|
||||||
this.initPhysics();
|
await this.initPhysics();
|
||||||
|
|
||||||
if (opts.ar) {
|
if (opts.ar) {
|
||||||
renderer.xr.enabled = true;
|
renderer.xr.enabled = true;
|
||||||
@@ -246,17 +246,17 @@ class GameEngine {
|
|||||||
this.cameraYaw = yaw;
|
this.cameraYaw = yaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
initPhysics() {
|
async initPhysics() {
|
||||||
//const world = new CANNON.World()
|
//const world = new CANNON.World()
|
||||||
//world.gravity.set(0, -9.82, 0)
|
//world.gravity.set(0, -9.82, 0)
|
||||||
let gravity = { x: 0.0, y: -9.81, z: 0.0 };
|
// let gravity = { x: 0.0, y: -9.81, z: 0.0 };
|
||||||
let world = new RAPIER.World(gravity);
|
// let world = new RAPIER.World(gravity);
|
||||||
|
|
||||||
// Create Ground.
|
// // Create Ground.
|
||||||
let bodyDesc = RAPIER.RigidBodyDesc.fixed();
|
// let bodyDesc = RAPIER.RigidBodyDesc.fixed();
|
||||||
let body = world.createRigidBody(bodyDesc);
|
// let body = world.createRigidBody(bodyDesc);
|
||||||
let colliderDesc = RAPIER.ColliderDesc.cuboid(100.0, 0.1, 100.0);
|
// let colliderDesc = RAPIER.ColliderDesc.cuboid(100.0, 0.1, 100.0);
|
||||||
world.createCollider(colliderDesc, body.handle);
|
// world.createCollider(colliderDesc, body.handle);
|
||||||
|
|
||||||
// const groundMaterial = new CANNON.Material('groundMaterial')
|
// const groundMaterial = new CANNON.Material('groundMaterial')
|
||||||
// const slipperyMaterial = new CANNON.Material('slipperyMaterial')
|
// const slipperyMaterial = new CANNON.Material('slipperyMaterial')
|
||||||
@@ -276,10 +276,9 @@ class GameEngine {
|
|||||||
// planeBody.addShape(planeShape)
|
// planeBody.addShape(planeShape)
|
||||||
// planeBody.quaternion.setFromAxisAngle(new CANNON.Vec3(1, 0, 0), -Math.PI / 2)
|
// planeBody.quaternion.setFromAxisAngle(new CANNON.Vec3(1, 0, 0), -Math.PI / 2)
|
||||||
// world.addBody(planeBody)
|
// world.addBody(planeBody)
|
||||||
this.phy = {
|
|
||||||
world,
|
this.phy = new Physics();
|
||||||
//slipperyMaterial
|
await this.phy.init();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleXrAction(gameEngine, delta) {
|
handleXrAction(gameEngine, delta) {
|
||||||
|
|||||||
Reference in New Issue
Block a user