Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7634419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:10:06+00:00 2026-05-31T07:10:06+00:00

I am trying to attach a simple image on a PlaneGeometry Mesh but it

  • 0

I am trying to attach a simple image on a PlaneGeometry Mesh but it doesn’t seem to work.

window.onload = function(){


        var renderer = new THREE.WebGLRenderer();
        renderer.setSize(window.innerWidth, window.innerHeight);
        document.body.appendChild(renderer.domElement);

        // camera
        var camera = new THREE.PerspectiveCamera(95, window.innerWidth / window.innerHeight, 1, 1000);
        camera.position.y = -250;
        camera.position.z = 400;
        camera.rotation.x = 45 * (Math.PI / 180);

        // scene
        var scene = new THREE.Scene();

        var img = new THREE.MeshLambertMaterial({
            map:THREE.ImageUtils.loadTexture('img/front.jpg')
        });
        // plane
        var plane = new THREE.Mesh(new THREE.PlaneGeometry(200, 200),img);
        plane.overdraw = true;
        scene.add(plane);
         // add subtle ambient lighting
        var ambientLight = new THREE.AmbientLight(0x555555);
        scene.add(ambientLight);

        // add directional light source
        var directionalLight = new THREE.DirectionalLight(0xffffff);
        directionalLight.position.set(1, 1, 1).normalize();
        scene.add(directionalLight);

        // create wrapper object that contains three.js objects
        var three = {
            renderer: renderer,
            camera: camera,
            scene: scene,
            plane: plane
        };
        renderer.render(scene,camera);
    };

This is my full javascript file with a canvas of 580×300

I only see a black square whenever I run it. any ideas? Thanks!

here is my reference for those who need it:

http://www.html5canvastutorials.com/webgl/html5-canvas-webgl-texture-with-three-js/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:10:08+00:00Added an answer on May 31, 2026 at 7:10 am

    After downloading latest tag from github and playing with examples it became clear that the CORS is the one to blame. If I open the Chrome Developper Tools and look at the console there are many error messages:

    Cross-origin image load denied by Cross-Origin Resource Sharing policy.
    

    If you are using Chrome, start it with flag -allow-file-access-from-files

    Tested with Chrome 17.0.963.79.

    window.onload = function(){
    
        var renderer = new THREE.WebGLRenderer();
        renderer.setSize(window.innerWidth, window.innerHeight);
        document.body.appendChild(renderer.domElement);
    
        // camera 
        var camera = new THREE.PerspectiveCamera(95, window.innerWidth / window.innerHeight, 1, 1000); 
        camera.position.y = -250; 
        camera.position.z = 400; 
        camera.rotation.x = 45 * (Math.PI / 180); 
    
        // scene 
        var scene = new THREE.Scene();
        scene.add(camera); //ADDED
    
        var img = new THREE.MeshBasicMaterial({ //CHANGED to MeshBasicMaterial
            map:THREE.ImageUtils.loadTexture('img/front.jpg')
        });
        img.map.needsUpdate = true; //ADDED
    
        // plane
        var plane = new THREE.Mesh(new THREE.PlaneGeometry(200, 200),img);
        plane.overdraw = true;
        scene.add(plane);
    
         // add subtle ambient lighting
        var ambientLight = new THREE.AmbientLight(0x555555);
        scene.add(ambientLight);
    
        // add directional light source
        var directionalLight = new THREE.DirectionalLight(0xffffff);
        directionalLight.position.set(1, 1, 1).normalize();
        scene.add(directionalLight);
    
        // create wrapper object that contains three.js objects
        var three = {
            renderer: renderer,
            camera: camera,
            scene: scene,
            plane: plane
        };
        renderer.render(scene,camera);
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to attach an entity in LINQ to SQL but it throws the
I am trying to attach a function-object to be called on destruction of a
I'm trying to find a simple way to attach click events to an element,
I've a simple table with only one column UrzadSkarbowyWojewodztwo that I'm trying to attach
I'm trying to integrate paperclip into a simple comment thread so users can attach
I'm trying to attach a simple focus/blur event listener via the .live() jQuery method
I'm trying to attach a PDF attachment to an email being sent with System.Net.Mail.
I'm trying to attach an external mdf file to my SQLEXPRESS instance from within
I'm trying to attach my database on a server that is running SQL2005 and
I'm trying to attach < Previous and Next > links to a jQueryUI datepicker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.