- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个简单的 THREE.js 应用程序,它呈现一个立方体并在每个面上应用纹理,如下所示:
var cubeGeometry = new THREE.CubeGeometry(5, 8, 1, 4, 4, 1);
var materials = [ new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture('front.jpg') }),
//.....Front, back, left, etc...
];
...
var cubeMesh = new THREE.Mesh(cubeGeometry, new THREE.MeshFaceMaterial(materials));
但是,我所看到的只是一个黑色的立方体,即图像没有出现在立方体的表面上。
此外,我的代码在 THREE.js 库的第 50 版中运行良好,因此似乎是更新版本的更改导致我的代码中断,而且我似乎找不到任何相关文档。
感谢任何帮助。
最佳答案
以下代码应从版本 97 开始工作
// creates cubes geometry in front of camera (assuming your camera position and rotation has not changed)
var geometry = new THREE.CubeGeometry(1, 1, 1, -2, 0, 0);
// creates a texture loader for the cube
var texture = new THREE.TextureLoader();
// defines variables to make things easier
var counter, textures = [], materials = [];
// iterate through all 6 sides of the cube
for(counter = 0; counter < 6; counter ++) {
// loads and stores a texture (you might run into some problems with loading images directly from a source because of security protocols, so copying the image data is a for sure way to get the image to load)
textures[counter] = texture.load('data:image/restOfImageAddress');
// creates material from previously stored texture
materials.push(new THREE.MeshBasicMaterial({map: textures[counter]}));
}
// creates the cube by mixing the geometry and materials
var cubeMesh = new THREE.Mesh(geometry, materials);
关于three.js - 使用 THREE.js 在立方体几何体上应用纹理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13667182/
我想计算一条线之间的交点: l := direction * x + origin for x e R or x e [0,R+) 和默认的 Boost 多边形。在文档中我只发现了与线段(固定起点和终
我有一个 blender 文件,我将其导出为 DAE/collada,然后使用 Xcode 将其转换为 Scenekit 的场景文件。我在使用场景文件中的几何体时遇到问题。 场景文件(“model.s
我正在开发一些用于生成 3D 模型的 webgl 软件,并且依赖于动态几何。我观察到了一些非常奇怪的行为,我已经能够在 this jsfiddle 中隔离这些行为。 . 似乎在将几何体实例添加到场景后
我们正在尝试构建“编辑 handle ”,允许用户通过在 8 个位置(4 个 Angular + 4 个边)之一拖动来调整(投影)平面的大小。这种调整大小应该只在拖动的方向上缩放/拉伸(stretch
我创建了一个渲染四边形的简单程序 初始化: Math::float3 vertices[4]; vertices[0] = Math::float3(-0.5f, 0.5f, -1.0f); vert
这里是定义我的简单 3D 几何体的点。 datN = {{{-0.47150460764747554`, 0.29559274991660417`, 0.010131794240974218`},
有没有办法在 3d 中定义形状 var x = 0, y = 0, z=0 ; var heartShape = 新三。 形状 (); heartShape.moveTo( x + 25, y + 2
我正在使用网络 worker 加载动画 3D 模型的 .json 文件。对于每个大数组(顶点、法线等),我将一个 Float32Array 缓冲区传输回 UI 线程。由于此类缓冲区是 transfer
我是一名优秀的程序员,十分优秀!