Skip to content

Commit bf142bc

Browse files
authored
fix: replace pokeball experiment (#222)
* fix: replaced pokeball with damaged helmet to avoid IP issues * refactor: update David component to use brick models and adjust related logic - Changed model paths from 'legolangelo' to 'brickelangelo' for David and brick pieces. * refactor: just changed the description
1 parent 3a0be29 commit bf142bc

File tree

17 files changed

+32
-1742
lines changed

17 files changed

+32
-1742
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<script setup lang="ts">
22
import type { Group } from 'three'
3-
import { InstancedMesh, MeshPhongMaterial, Raycaster, Vector3, Object3D } from 'three'
3+
import { InstancedMesh, MeshPhongMaterial, Vector3, Object3D } from 'three'
44
import { MeshSurfaceSampler } from 'three/addons/math/MeshSurfaceSampler.js'
55
import { useMouse } from '@vueuse/core'
66
77
const groupRef = ref<Group>()
88
9-
const gltf = await useGLTF('/models/legolangelo/david.glb')
9+
const gltf = await useGLTF('/models/brickelangelo/david.glb')
1010
1111
const david = gltf.nodes.David
1212
@@ -17,12 +17,12 @@ watch([x, y], () => {
1717
groupRef.value.rotation.y = -x.value * 0.0001
1818
})
1919
20-
const { nodes: legoNodes } = await useGLTF('/models/legolangelo/lego.glb')
20+
const { nodes: brickNodes } = await useGLTF('/models/brickelangelo/brick.glb')
2121
22-
const lego = legoNodes.LegoPiece
22+
const brick = brickNodes.LegoPiece
2323
24-
const legoMaterial = new MeshPhongMaterial({ color: 'lightgray' })
25-
const legoInstancedMesh = new InstancedMesh(lego.geometry, legoMaterial, instanceCount)
24+
const brickMaterial = new MeshPhongMaterial({ color: 'lightgray' })
25+
const brickInstancedMesh = new InstancedMesh(brick.geometry, brickMaterial, instanceCount)
2626
2727
useControls('fpsgraph')
2828
@@ -32,30 +32,30 @@ const sampler = new MeshSurfaceSampler(david)
3232
3333
const instanceCount = 75000 // or whatever count you want
3434
const dummy = new Object3D()
35-
const legoSize = 0.03 // Define according to the size of your LEGO piece
35+
const brickSize = 0.03 // Define according to the size of your brick piece
3636
3737
for (let i = 0; i < instanceCount; i++) {
3838
const sampledPoint = new Vector3()
3939
sampler.sample(sampledPoint)
4040
4141
const alignedPoint = new Vector3(
42-
Math.round(sampledPoint.x / legoSize) * legoSize,
43-
Math.round(sampledPoint.y / legoSize) * legoSize,
44-
Math.round(sampledPoint.z / legoSize) * legoSize,
42+
Math.round(sampledPoint.x / brickSize) * brickSize,
43+
Math.round(sampledPoint.y / brickSize) * brickSize,
44+
Math.round(sampledPoint.z / brickSize) * brickSize,
4545
)
4646
4747
dummy.position.copy(alignedPoint)
48-
dummy.scale.set(legoSize, legoSize, legoSize)
48+
dummy.scale.set(brickSize, brickSize, brickSize)
4949
dummy.updateMatrix()
50-
legoInstancedMesh.setMatrixAt(i, dummy.matrix)
50+
brickInstancedMesh.setMatrixAt(i, dummy.matrix)
5151
}
5252
53-
legoInstancedMesh.instanceMatrix.needsUpdate = true
53+
brickInstancedMesh.instanceMatrix.needsUpdate = true
5454
</script>
5555

5656
<template>
5757
<TresGroup ref="groupRef">
58-
<primitive :object="legoInstancedMesh" />
58+
<primitive :object="brickInstancedMesh" />
5959
</TresGroup>
6060
<!-- <primitive :object="david" /> -->
6161
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script setup lang="ts">
2+
const { scene } = await useGLTF('/models/damaged-helmet/DamagedHelmet.glb', { draco: true })
3+
</script>
4+
5+
<template>
6+
<primitive :object="scene" />
7+
</template>

components/content/realistic/Pokeball.vue

-9
This file was deleted.

components/content/realistic/index.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ const { hasFinishLoading, progress } = await useProgress()
1515
>
1616
<div class="w-200px">
1717
Loading... {{ progress }} %
18-
<i class="i-ic-twotone-catching-pokemon animate-rotate-in" />
18+
<i class="animate-rotate-in" />
1919
</div>
2020
</div>
2121
</Transition>
2222
<TresCanvas preset="realistic">
23-
<TresPerspectiveCamera :position="[11, 11, 11]" />
23+
<TresPerspectiveCamera :position="[3, 3, 5]" />
2424
<OrbitControls />
2525
<Suspense>
2626
<Environment
@@ -30,7 +30,7 @@ const { hasFinishLoading, progress } = await useProgress()
3030
/>
3131
</Suspense>
3232
<Suspense>
33-
<Pokeball />
33+
<DamagedHelmet />
3434
</Suspense>
3535

3636
<TresDirectionalLight

content/experiments/brickelangelo-david.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
author: alvarosabu
3-
description: Lego ThreeJS Journey challenge
3+
description: Bricks ThreeJS Journey challenge
44
tags: ['basic', 'cientos', 'MeshSurfaceSampler']
55
---
66

3.6 MB
Binary file not shown.
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Flight helmet with damage
2+
Credit:
3+
© 2018, ctxwing. [CC BY 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode)
4+
- ctxwing for Rebuild and conversion to glTF
5+
© 2016, theblueturtle_. [CC BY-NC 4.0 International](https://creativecommons.org/licenses/by-nc/4.0/legalcode)
6+
- theblueturtle_ for Earlier version of model

public/models/nuxt-stones/nuxt-stones.gltf

+1-1
Large diffs are not rendered by default.

public/models/realistic-pokeball/license.txt

-11
This file was deleted.
-5.97 MB
Binary file not shown.

0 commit comments

Comments
 (0)