我正在尝试使用 WEBGL 在 P5js 中使用图像作为平面的纹理,但由于某种原因它不起作用。
我试图摆脱所有的照明,只使用ambientLight(),但它仍然没有显示。我已经尝试在一个只有平面和相同代码的新草图中,它工作正常,所以我不明白这个草图中的问题是什么?
let bodyShape;
let spacing = 50;
let bgTexture;
function preload() {
bodyShape = loadModel('Human_body_with_net.obj');
bgTexture = loadImage('assets/gormleyline.jpeg');
}
function setup() {
createCanvas(600, 600,WEBGL);
noStroke();
}
function draw() {
background(0);
debugMode();
orbitControl();
ambientLight(255);
// pointLight(102,0,0,0,1,0);
// pointLight(0,102,255,1,0,0);
// directionalLight(255,0,0,0,1,0);
// directionalLight(255,255,255,0,0,-1);
// pointLight(0,0,0,mouseX,mouseY,0);
backgroundShape();
push();
translate(-260,0,0);
for (let x = 0; x<10; x++){
bodyFunction(x+spacing,0,0);
rotateX(50);
}
pop();
}
function bodyFunction(x,y,z,rotation){
specularMaterial(255);
translate(x,y,z);
rotateX(HALF_PI);
model(bodyShape);
}
function backgroundShape(){
push();
translate(0,0,-130);
plane(600,600);
texture(bgTexture)
pop();
}
这是草图的链接,以防万一:https://editor.p5js.org/rociorey/sketches/4H1eFQpKh
谢谢!