-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3d6356
commit 5d81420
Showing
17 changed files
with
77 additions
and
44 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import * as THREE from "three"; | ||
import { AsciiEffect } from "three/addons/effects/AsciiEffect.js"; | ||
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js"; | ||
|
||
const scene = new THREE.Scene(); | ||
const camera = new THREE.PerspectiveCamera( | ||
75, | ||
window.innerWidth / window.innerHeight, | ||
0.1, | ||
1000 | ||
); | ||
|
||
const renderer = new THREE.WebGLRenderer(); | ||
renderer.setSize(window.innerWidth, window.innerHeight); | ||
camera.position.z = 5; | ||
|
||
const effect = new AsciiEffect(renderer, " .:-+*=%@#", { invert: true }); | ||
effect.setSize(window.innerWidth, window.innerHeight); | ||
|
||
document.body.appendChild(effect.domElement); | ||
effect.domElement.style.color = "white"; | ||
effect.domElement.style.backgroundColor = "black"; | ||
effect.domElement.style.position = "fixed"; | ||
effect.domElement.style.top = "0"; | ||
effect.domElement.style.left = "0"; | ||
effect.domElement.style.opacity = "0.1"; | ||
effect.domElement.style.zIndex = "-1"; | ||
|
||
const loader = new GLTFLoader(); | ||
|
||
let model = null; | ||
loader.load("star.glb", function (gltf) { | ||
model = gltf.scene.children[0]; | ||
model.material = new THREE.MeshBasicMaterial({ | ||
color: 0x00ff00, | ||
}); | ||
model.scale.set(0.5, 0.5, 0.5); | ||
scene.add(model); | ||
}); | ||
|
||
function animate() { | ||
requestAnimationFrame(animate); | ||
|
||
if (model) { | ||
model.rotation.x += 0.01; | ||
model.rotation.y += 0.01; | ||
model.rotation.z += 0.01; | ||
} | ||
|
||
effect.render(scene, camera); | ||
} | ||
|
||
animate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters