Skip to content

Commit 98d6605

Browse files
committed
ups.. revert to vec3
1 parent a3e61b7 commit 98d6605

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"rimraf": "^3.0.2",
4848
"sweetalert": "^2.1.2",
4949
"three": "^0.125.0",
50+
"vec3": "^0.1.7",
5051
"webpack-dev-server": "^3.11.1",
5152
"webpack-merge": "^5.7.3",
5253
"worker-loader": "^3.0.7"

src/scripts/proxy/Proxy.worker.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-env worker */
2-
import { Vector3 } from 'three'
2+
import vec3 from 'vec3'
33
import Convert from 'ansi-to-html'
44
const convert = new Convert()
55

@@ -154,7 +154,7 @@ addEventListener('message', function (e) {
154154
}
155155
break
156156
case 'dig':
157-
block = bot.blockAt(new Vector3(data[0][0], data[0][1] - 16, data[0][2]))
157+
block = bot.blockAt(vec3(data[0][0], data[0][1] - 16, data[0][2]))
158158
if (block !== null) {
159159
const digTime = bot.digTime(block)
160160
if (bot.targetDigBlock !== null) {
@@ -190,10 +190,10 @@ addEventListener('message', function (e) {
190190
}
191191
break
192192
case 'blockPlace':
193-
block = bot.blockAt(new Vector3(...data[0]))
193+
block = bot.blockAt(vec3(...data[0]))
194194
if (bot.heldItem !== undefined && bot.heldItem !== null) {
195195
// console.log(heldItem);
196-
bot.placeBlock(block, new Vector3(...data[1]))
196+
bot.placeBlock(block, vec3(...data[1]))
197197
}
198198
break
199199
}

src/scripts/world/ChunkManager.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { BufferGeometry, BufferAttribute, Mesh, Vector3 } from 'three'
1+
import { BufferGeometry, BufferAttribute, Mesh } from 'three'
2+
import vec3 from 'vec3'
23

34
class ChunkManager {
45
constructor (game) {
@@ -44,8 +45,8 @@ class ChunkManager {
4445

4546
updateRenderOrder (cell) {
4647
for (const [k, v] of this.cellMesh) {
47-
const x = new Vector3(this.game.world.chunkTerrain.strToVec(k))
48-
v.renderOrder = -new Vector3(...cell).distanceTo(x)
48+
const x = vec3(this.game.world.chunkTerrain.strToVec(k))
49+
v.renderOrder = -vec3(...cell).distanceTo(x)
4950
}
5051
}
5152

src/scripts/world/chunk.worker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { ChunkTerrain } from './ChunkTerrain.js'
33
import { ChunkMesher } from './ChunkMesher.js'
44
import raf from 'raf'
5-
import { Vector3 } from 'three'
5+
import vec3 from 'vec3'
66

77
self.requestAnimationFrame = raf
88
let terrain = null
@@ -34,8 +34,8 @@ class TerrainManager {
3434

3535
distance (chunkId) {
3636
const data = this.chunkTerrain.strToVec(chunkId)
37-
const chunk = new Vector3(...data)
38-
const chunkP = new Vector3(...this.playerChunk)
37+
const chunk = vec3(...data)
38+
const chunkP = vec3(...this.playerChunk)
3939
return chunkP.distanceTo(chunk)
4040
}
4141

0 commit comments

Comments
 (0)