我想问你是否知道如何使用THREE.TextureLoader()重复纹理.我找到了仅使用THREE.ImageUtils.loadTexture()的解决方案.这是我的代码的一部分:
var loader = new THREE.TextureLoader();
var wall;
loader.load('../images/concreteWall.jpg', function (texture) {
var wallMaterial = new THREE.MeshBasicMaterial({
map: texture
});
wall = new THREE.Mesh(sideWallsGeometry, wallMaterial);
scene.add(wall);
}
);
Run Code Online (Sandbox Code Playgroud) 我有一个Meshes数组,每个Mesh都在name属性中存储了它的ID.我想问你,是否可以从场景中删除具有特定ID的对象.像这样的东西.
var geo = some geometry;
var mat = some material;
for (var i = 0; i < 10; i++) {
var object = new THREE.Mesh(geo, mat);
object.name = i; // i would serve as ID in this case
}
Run Code Online (Sandbox Code Playgroud)
在此之后,我想删除/删除其中的一些对象......也许有些功能就像
remove(id);
Run Code Online (Sandbox Code Playgroud)
....
var remove = function (id) {
... some magic
scene.remove(...) // and this would remove that object, with id passed as parameter
}
Run Code Online (Sandbox Code Playgroud)
这样的事情可能吗?
谢谢!
我在 Nuxt 中有一个应用程序,我想将购物车的内容存储在 cookie 中。为了存储 cookie,我使用cookie-universal-nuxt包。但是,我无法在其中存储“某些”对象。下面是一个例子:
const userInfo = {
name: 'Smith',
age: 41,
isVip: true,
}
this.$cookies.set('userInfo', JSON.stringify(userInfo))
console.log(this.$cookies.get('userInfo'))
Run Code Online (Sandbox Code Playgroud)
这可以正常工作,没有问题。问题是,它不适用于我的真实物体:
const savedProductsArray = this.$store.getters['cart/products'] // returns array of products
const savedProducts = savedProductsArray[0] // select first one
this.$cookies.set('productInfo', JSON.stringify(savedProducts))
console.log(this.$cookies.get('productInfo')) // prints undefined
Run Code Online (Sandbox Code Playgroud)
所以第二个对象显然没有存储在 cookie 中。知道为什么吗?谢谢!
顺便说一句,这是 userInfo 对象在控制台中的样子:
Object {
age: 41,
name: "Smith",
isVip: true,
}
Run Code Online (Sandbox Code Playgroud)
并保存产品:
Object {
calories: 123,
name: "a",
...
}
Run Code Online (Sandbox Code Playgroud)
所以看起来它们是“相同”的对象,但不知何故只有第一个可以存储在cookies中......