Skip to content

Commit

Permalink
new build
Browse files Browse the repository at this point in the history
  • Loading branch information
RingoKam committed Jan 2, 2024
1 parent 6b702c8 commit 0cecf87
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 81 deletions.
Binary file added docs/audio/charging.mp3
Binary file not shown.
Binary file added docs/audio/correct.mp3
Binary file not shown.
Binary file added docs/audio/gameover.mp3
Binary file not shown.
287 changes: 207 additions & 80 deletions docs/index.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.bundle.js.map

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions docs/referenceImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { TextureLoader, PlaneGeometry, MeshBasicMaterial, Vector3, Mesh } from 'three'

let signImage;
var right = new Vector3(1, 0, 0);

const setupReferenceImage = (scene) => {
const mesh = loadImage('img/asl_signs.png')
const size = 0;
mesh.scale.set(size, size, size)
scene.add(mesh)
signImage = mesh
}

function loadImage(imagePath) {
const textureLoader = new TextureLoader();
const texture = textureLoader.load(imagePath);
const geometry = new PlaneGeometry(1, 1);
const material = new MeshBasicMaterial({ map: texture });
const mesh = new Mesh(geometry, material);

return mesh;
}

const enlargeScale = 0.25;
const shrinkScale = 0.05;
let once = false
const followPlayerHand = (hand) => {
// console.log(hand.getWorldPosition())
// get hand position
// is hand model inside facing up?
// if so, enlarge image
// else, shrink image
right.applyQuaternion(hand.quaternion);
right.normalize();
const dot = right.dot(new Vector3(0, 1, 0));

if(!once) {
hand.add(signImage)
once = true
}

if(dot > 0.1) {
signImage.scale.set(enlargeScale, enlargeScale, enlargeScale)
} else {
signImage.scale.set(shrinkScale, shrinkScale, shrinkScale)
}
}

export {
setupReferenceImage,
followPlayerHand
}

0 comments on commit 0cecf87

Please sign in to comment.