The examples in this branch are based on r63 and correspond to the second edition of "Learning Three.js"
The examples for the third edition of this book can be found in the following repo
Code repository for the examples from the Packt book "Learning Threejs"
The examples in this branch are based on r63 and correspond to the second edition of "Learning Three.js"
The examples for the third edition of this book can be found in the following repo
Error is Uncaught TypeError: Cannot read property 'amount' of undefined !!
I update chapter-06\05-extrude-svg.html. you can see below
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="1152px" height="1152px" xml:space="preserve"> <g id="landmarks"> <path id="batman-path" style="fill:rgb(0,0,0);" d="M 261.135 114.535 C 254.906 116.662 247.491 ,,,,,"/> <path id="batman-path2" style="fill:rgb(0,0,0)" d="M550.1 163.4 L576.5 170.5 L579.4 174.8 L606 169.6 L641.3 181.3 L669 220.2 L593.7 236.1 L584.9 222.6 L595.2 220.5 L586.2 206.7 L539.8 216.1 L524.8 239.1 L471.9 250.1 L461.4 231.3 L471.1 229.4 L464.8 218.1 L455.1 220.1 L435.6 185.1 Z"/> </g> </svg>
But It can't run. I am boring so that I can't make progress in this week. I hope you can help me.
All code are below:
`
var shapearr=[];
var shape, svgString;
var paths=document.querySelectorAll("svg > path[id]")
for(var i = 0; i < paths.length; i++) {
var path = paths[i];
svgString=path.getAttribute('d');
console.log(svgString);
//shape = transformSVGPathExposed(svgString);
shape=createMesh(new THREE.ShapeGeometry(drawShape2(svgString)));
scene.add(shape);
shapearr.push(shape);
}
.....
var controls = new function () {
this.amount =6; //2;
this.bevelThickness = 2;
this.bevelSize = 0.5;
this.bevelEnabled = true;
this.bevelSegments = 3;
this.bevelEnabled = true;
this.curveSegments = 12;
this.steps = 1;
this.asGeom = function () {
scene.remove(shape);
var options = {
amount: controls.amount,
bevelThickness: controls.bevelThickness,
bevelSize: controls.bevelSize,
bevelSegments: controls.bevelSegments,
bevelEnabled: controls.bevelEnabled,
curveSegments: controls.curveSegments,
steps: controls.steps
};
var paths=document.querySelectorAll("svg > path[id]")
console.log(shapearr);
for(var i = 0; i < paths.length; i++) {
var path = paths[i];
svgString=path.getAttribute('d');
console.log(svgString);
// shape = transformSVGPathExposed(svgString);
shape=createMesh(new THREE.ExtrudeGeometry(drawShape2(svgString)),options);
scene.add(shape);
}
};
};
``
In:【 learning-threejs/chapter-01/02-first-scene.html 】
the method setClearColorHex() has changed to setClearColor() ?
I am a bit confused about the point selected by the author. Why new THREE.Vector3(-30, 39.8, 30)
IMHO, it should be camera.position, since I want to draw a barrel from the camera to the intersection point, but it does not seem to work either.
when use the big vedio as the texture to the box, it will stop at a point.
This problem prevents me from opening this example, I have tried to replace the model with different glTF 2.0 files, but the same error exists. I'm using npm and python simple server to open the example.
error message here.
Uncaught TypeError: Cannot read property 'match' of undefined
at Object.value (glTF-parser.js:91)
at Object.value (glTF-parser.js:97)
at Object. (glTF-parser.js:113)
at Array.forEach ()
at Object. (glTF-parser.js:111)
at Array.forEach ()
at Object.value (glTF-parser.js:107)
at Object.set [as json] (glTF-parser.js:133)
at XMLHttpRequest. (glTF-parser.js:276)
When I use DeviceOrientationControls, the orientation angle data obtained by different mobile phones are inconsistent. What is the problem?
https://threejs.org/docs/#api/geometries/RingGeometry
from document, ring geometry is 2D geometry, not 3D.
file name 03-basic-3d-geometries-ring.html, 08-basic-3d-geometries-ring.html
should be change to 2d.
I confused about this. I saw example. Only 2D geometry.
There is no 3D Ring geometry. I think this is maybe torus geometry.
Thank you.
Error message from Javascript console:
Uncaught TypeError: Cannot read property 'getShaderPrecisionFormat' of null
This line is responsible:
var renderer = new THREE.WebGLRenderer();
However, it does render on Firefox. OS: Ubuntu 15.04.
只是介绍啊?
I've come across two typos in Chapter 1 so far.
var spotLight = new THREE.SpotLight(0xFFFFFF);
spotLight.position.set(-40, 40, -15);
spotLight.castShadow = true;
spotLight.shadow.mapSize = new THREE.Vector2(1024, 1024);
spotLight.shadow.camera.far = 130;
spotLight.shadow.camera.near = 40;
This won't work without scene.add(spotLight);
renderer.setClearColor(new THREE.Color(0x000000));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.Enabled = true;
should be renderer.shadowMap.enabled
flyControls.domElement = document.querySelector("webgl-output");
should be:
flyControls.domElement = document.querySelector("#webgl-output");
am newbie to three js and learning now. i need to create a circle geometry and faceVertexUvs.
var radius = 3,
segments = 32,
material = new THREE.LineBasicMaterial({color: 0xFF0000}),
geometry = new THREE.CircleGeometry(radius, segments);
var circle = new THREE.Line(geometry, material);
circle.position.set(5, 6, 0);
scene.add(circle);
This is creating an eclipse but not circle. Please help me where am wrong..?
Uncaught TypeError: Cannot read property 'match' of undefined
Object.create._isAbsolutePath.value @ glTF-parser.js:91
Object.create.resolvePathIfNeeded.value @ glTF-parser.js:97
(anonymous function) @ glTF-parser.js:113
(anonymous function) @ glTF-parser.js:111
Object.create._resolvePathsForCategories.value @ glTF-parser.js:107
Object.create.json.set @ glTF-parser.js:133
(anonymous function) @ glTF-parser.js:276
Hello,
The book refers to PathControl code in example 09-path-controls.html
.
However, it is not in the code I see here online. Also did a search of "This repository" for "PathControl" and nothing turned up.
Thanks
When running chapter 7-10 particle system from model, with the recent version of THREE.js I get a defined edge or visible bounding box around the gradients. Is there something that needs to be changed to make it look smooth as it does in the previous version or the version used in the book?
chapter-09, thks
learning-threejs/chapter-02/04-geometries.html
Tried to use the SceneExporter code to export a scene to a JSON object. Got this error.
Uncaught TypeError: Expecting a function in instanceof check, but got undefined
From Chapter Eleven 02-post-processing-simple-passes.html, where is the noise coming from in var effectFilm = new THREE.FilmPass(0.8, 0.325, 256, false);
?
The orbiting is not causing the noise effect, because when I remove the orbit animation, it is still there.
It's not coming from the textures, because when I remove them, the noise effect is still there.
I've tried using THREE.FilmPass()
in my own experiment and I can not make the noise effect. Instead, I just get the normal scan line effect without the noise.
var renderPass = new THREE.RenderPass(scene, camera);
var effectFilm = new THREE.FilmPass();
effectFilm.uniforms.grayscale.value = false;
effectFilm.uniforms.nIntensity.value = 3;
effectFilm.uniforms.sIntensity.value = .3;
effectFilm.uniforms.sCount.value = 2048;
effectFilm.renderToScreen = true;
var composer = new THREE.EffectComposer(renderer);
composer.addPass(renderPass);
composer.addPass(effectFilm);
Codes don't work since THREE.SceneExporter isn't supported.
"Attempted import error: 'SceneExporter' is not exported from 'three' (imported as 'THREE')"
Is there any way to replace THREE.SceneExoprter? Thanks
Specifying type attributes <script>
tag is not necessary as HTML5 implies text/javascript as defaults. This can be safely done even for older browsers.
09-path-controlls.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.