Skip to content

Commit 5d079a4

Browse files
committed
add: sword smallBlinks.
1 parent e259f4d commit 5d079a4

File tree

4 files changed

+63
-23
lines changed

4 files changed

+63
-23
lines changed

Maria.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,6 @@ class Maria {
829829
this.swordBlink = new SwordBlink()
830830
// scene.add(swordBlink.mesh)
831831
this.swordDelegate.add(this.swordBlink.mesh)
832-
this.swordDelegate.add(this.swordBlink.mesh2)
833832

834833
//
835834

SwordBlink.js

Lines changed: 62 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@ class SwordBlink {
55
constructor() {
66
// updates.push(this)
77

8+
this.mesh = new THREE.Group()
9+
10+
this.tmpVec3 = new THREE.Vector3()
11+
this.mainBlinkScale = 0.8
12+
this.smallBlinkScale = 0.1
13+
814
let geometry = new THREE.PlaneGeometry(1, 3)
915
// let scale = 1000
1016
let scale = 300
1117
// let scale = 200
1218
// let scale = 100
13-
geometry.scale(scale, scale, scale)
19+
geometry.scale(scale * 0.7, scale, scale)
1420
// let geometry = new THREE.BoxGeometry()
1521
let map = new THREE.TextureLoader().load('./image/SwordBlink.png')
1622
map.encoding = THREE.sRGBEncoding
17-
let material = new THREE.MeshBasicMaterial({
23+
this.material = new THREE.MeshBasicMaterial({
1824
map,
1925
transparent: true,
2026
// blending: THREE.AdditiveBlending,
@@ -23,48 +29,83 @@ class SwordBlink {
2329
depthWrite: false,
2430
side: THREE.DoubleSide,
2531
})
26-
this.mesh = new THREE.Mesh(geometry, material)
32+
this.mainBlink = new THREE.Mesh(geometry, this.material)
33+
34+
this.mainBlink.renderOrder = 1000
35+
36+
this.mainBlink.rotation.x = Math.PI / 2
37+
38+
// this.mainBlink.scale.setScalar(100)
39+
40+
this.mainBlink2 = this.mainBlink.clone()
41+
this.mainBlink2.rotation.y = Math.PI / 2
2742

28-
this.mesh.renderOrder = 1000
43+
this.mesh.add(this.mainBlink)
44+
this.mesh.add(this.mainBlink2)
2945

30-
this.mesh.rotation.x = Math.PI / 2
46+
//
3147

32-
// this.mesh.scale.setScalar(100)
48+
this.smallBlinks = []
49+
let smallGeometry = geometry.clone()
50+
smallGeometry.rotateX(Math.PI / 2)
51+
// smallGeometry.scale(1, 1, 1)
52+
this.smallMaterial = this.material.clone()
53+
for (let i = 0; i < 12; i++) {
54+
let smallBlink = new THREE.Mesh(smallGeometry, this.smallMaterial)
55+
smallBlink._position = new THREE.Vector3()
56+
// smallBlink.rotation.x += Math.PI / 2
57+
this.mesh.add(smallBlink)
58+
this.smallBlinks.push(smallBlink)
59+
}
3360

34-
this.mesh2 = this.mesh.clone()
35-
this.mesh2.rotation.y = Math.PI / 2
61+
//
3662

3763
this.mesh.visible = false
38-
this.mesh2.visible = false
3964
}
4065

4166
blink(chargedLevel) {
4267
let to = { t: 0, tv: 1 }
4368
gsap.to(to, {
44-
duration: 5 / 60,
45-
// duration: 1,
69+
duration: 10 / 60,
70+
// duration: 3,
4671
t: 1,
4772
tv: 0,
73+
ease: 'none',
4874
onStart: () => {
4975
this.mesh.visible = true
50-
this.mesh2.visible = true
51-
this.mesh.scale.setScalar(1)
52-
this.mesh2.scale.setScalar(1)
76+
this.mainBlink.scale.setScalar(this.mainBlinkScale)
77+
this.mainBlink2.scale.setScalar(this.mainBlinkScale)
78+
this.smallBlinks.forEach((smallBlink) => {
79+
smallBlink.scale.setScalar(this.smallBlinkScale)
80+
smallBlink._position.x = (Math.random() - 0.5) * 350
81+
smallBlink._position.y = (Math.random() - 0.5) * 350
82+
smallBlink._position.z = (Math.random() - 0.5) * 350
83+
smallBlink.position.x = smallBlink._position.x
84+
smallBlink.position.y = smallBlink._position.y
85+
smallBlink.position.z = smallBlink._position.z
86+
smallBlink.lookAt(this.mesh.getWorldPosition(this.tmpVec3))
87+
})
5388
if (chargedLevel === 1) {
54-
this.mesh.material.color.set('white')
55-
this.mesh2.material.color.set('white')
89+
this.material.color.setRGB(1, 1, 1)
90+
this.smallMaterial.color.setRGB(1, 1, 1)
5691
} else if (chargedLevel === 2) {
57-
this.mesh.material.color.set('cyan')
58-
this.mesh2.material.color.set('cyan')
92+
this.material.color.setRGB(0.5, 1, 1)
93+
this.smallMaterial.color.setRGB(0.5, 1, 1)
5994
}
6095
},
6196
onUpdate: () => {
62-
this.mesh.scale.setScalar(to.tv)
63-
this.mesh2.scale.setScalar(to.tv)
97+
this.mainBlink.scale.setScalar(this.mainBlinkScale * to.tv ** 0.5)
98+
this.mainBlink2.scale.setScalar(this.mainBlinkScale * to.tv ** 0.5)
99+
this.smallBlinks.forEach((smallBlink) => {
100+
smallBlink.scale.x = this.smallBlinkScale * to.tv
101+
smallBlink.position.x = smallBlink._position.x * to.tv
102+
smallBlink.position.y = smallBlink._position.y * to.tv
103+
smallBlink.position.z = smallBlink._position.z * to.tv
104+
})
105+
this.smallMaterial.opacity = to.tv
64106
},
65107
onComplete: () => {
66108
this.mesh.visible = false
67-
this.mesh2.visible = false
68109
},
69110
})
70111
}

image/SwordBlink.png

-421 Bytes
Loading

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ function init_three() {
321321
stats = new Stats()
322322
container.appendChild(stats.dom)
323323

324-
// window.controls = new OrbitControls(camera, renderer.domElement)
324+
if (g.getQueryStringByName('orbit') === 'true') window.controls = new OrbitControls(camera, renderer.domElement)
325325
}
326326

327327
function init_cannon() {

0 commit comments

Comments
 (0)