Add 3D Model to WebSite in 5 Minutes - Three.js Tutorial

Red Stapler · 567K views · 2019 · 5:57

Open on YouTube

Web developmentComputer graphics & renderingtutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as the starting-point tutorial for loading GLTF models in Three.js, and many questions about errors, imports or React integration start from code copied out of it.

Recommended by 1 people across 1 different months, 2020 to 2023.

What it is

A short screen-recorded tutorial from the Red Stapler channel showing how to load a 3D car model into a web page with Three.js, using GLTFLoader and OrbitControls to give a 360 degree view. It walks through the full HTML and JavaScript setup and links the source code and model.

What people said

Recommends Alin-Alexandru Peter · 2023-01 · Stack Overflow · on “Create a mesh from GLTFLaoder().load() in Thre.js”

I found out that actually by modifying the first function above like this: loader.load("path/to/model", gltf => { var object = gltf.scene.children[0]; scene.add(gltf.scene); }); is the solution. Because now object variable can be totally handled like a normal mesh. Maybe a video [this video] to help you.

Cites Santiago Camisay · 2020-01 · Stack Overflow · on “Add interactive points in a GLTF file”

I have a GLTF file and I want to add interactive points over it with Blender if possible. I start from an example code ( [this video] ) where I load a GTFL with three.js and render it into a canvas in HTML5. I need to add interaction sections like in this example: [LINK]

Cites mash · 2020-04 · Stack Overflow · on “Uncaught SyntaxError: Cannot use import statement outside a module”

[this video] <!DOCTYPE html> <html> <head> <title>Three.js</title> <style type="text/css"> html, body {margin: 0; padding: 0; overflow: hidden} </style> </head> <body> <div id="webgl"></div> <script src="three.js"></script> <script src="GLTFLoader.js"></script> <script> let scene,camera,renderer; function init(){ scene = new THREE.Scene(); scene.background = new THREE.Color(0xdddddd); camera = new THREE.PerspectiveCamera(40,window.innerWidth/window.innerHeight,1,5000); hlight = new THREE.AmbientLight(0x404040,100); scene.add(hlight); renderer = new THREE.WebGLRenderer({antialias:true}); renderer.setSize(window.innerWidth,window.innerHeight); document.getElementById('webgl').appendChild(renderer.d

Cites Jonas Blazinskas · 2020-05 · Stack Overflow · on “Three.js error Uncaught TypeError following a guide”

I have been following this guide to get three.js to work: [this video] I pasted his source code from the bottom of this website: [LINK] Downloaded the model and extracted it to the directory html Got the gtflloader and orbitcotrols from the links in the discription. I have created files with those names in the html directory and pasted the code in. And I got the three.min.js from the official three.js download folder and I have put it the html directory. I am getting this error. Is it me doing something wrong? Or the code is broken? If so what would be the fix? [LINK]

Cites Ripperakos · 2020-06 · Stack Overflow · on “Three.js Import 3d Model”

i have followed a couple of tutorials to import a 3d model. I have succeeded importing using A-Frame Tags, but when i try doing it with Three.js its not working. I have copy pasted the following code from a tutorial i found on youtube. [this video] <!DOCTYPE html> <html> <head> <meta charset=UTF-8 /> <link rel="stylesheet" type="text/css" href="main.css" /> </head> <body> <script src="three.js"></script> <script src="GLTFLoader.js"></script> <script src="OrbitControls.js"></script> <script> let scene, camera, renderer; function init() { scene = new THREE.Scene(); scene.background = new THREE.Color(0xdddddd); camera = new THREE.PerspectiveCamera(40,window.innerWidth/window.innerHeight,1,5000); cam

Cites Alin-Alexandru Peter · 2023-03 · Stack Overflow · on “Cannot read properties of null (reading "width") in Three.js React component”

I have a Three.js app and I have a problem. I have a few files: main.js: it looks exactly like the code from this [this video] video. All I did was to wrap everything into a function so I could load 5 3D models dinamically, and not create 5 js files that do the same. And the React component: import { displayObject } from "../main" export default function Atraction() { setTimeout(() => { displayObject(myArgs) }, 3000) return ( <canvas className="webgl-1"></canvas> ) } I get the error: Cannot read proprety of null(reading "width") It refers to the canvas element that I am trying to access. What should I do?