Skip to content

Instantly share code, notes, and snippets.

class Collectible {
constructor(mesh, onApply) {
this.mesh = new THREE.Object3D()
const bubble = new THREE.Mesh(
new THREE.SphereGeometry(10, 100, 100),
new THREE.MeshPhongMaterial({
color: COLOR_COLLECTIBLE_BUBBLE,
transparent: true,
opacity: .4,
flatShading: true,
class Enemy {
tick(deltaTime) {
...
const thisAabb = new THREE.Box3().setFromObject(this.mesh)
for (const projectile of allProjectiles) {
const projectileAabb = new THREE.Box3().setFromObject(projectile.mesh)
if (thisAabb.intersectsBox(projectileAabb)) {
spawnParticles(projectile.mesh.position.clone(), 5, Colors.brownDark, 1)
projectile.remove()
this.hitpoints -= projectile.damage
class SimpleGun {
downtime() {
return 0.1
}
damage() {
return 1
}
shoot(direction) {
@Badestrand
Badestrand / aviator2-simplegun.js
Last active April 18, 2022 04:09
aviator2-simplegun
const metalMaterial = new THREE.MeshStandardMaterial({
color: 0x222222,
flatShading: true,
roughness: 0.5,
metalness: 1.0
})
class SimpleGun {
static createMesh() {
const BODY_RADIUS = 3
@Badestrand
Badestrand / preact-mini.html
Last active July 23, 2023 03:48
Simple preact in browser
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style rel="stylesheet" type="text/less">
* {
margin: 0;
padding: 0;
@Badestrand
Badestrand / react-mini.html
Last active January 28, 2024 12:01
Simple React in browser
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style rel="stylesheet" type="text/less">
* {
margin: 0;
padding: 0;