Jump to content

[solved] Uncaught TypeError assigning Material to Mesh


Rook
 Share

Recommended Posts

I have a very basic setup, and it works in a Playground, but throws this error when I am running it in an Electron app (still very basic).  I have [email protected] saved as an npm dependency.

I have a Module that contains a class.  

Quote
var BABYLON = require('babylonjs')
 
class Star {
constructor (scene, starData) {
 
this.id = starData.id
this.name = starData.name
this.spectralColor = new BABYLON.Color3(1.0, 0.0, 0.0)
this.absmag = starData.absmag
 
// Create the mesh
var mesh = new BABYLON.MeshBuilder.CreateSphere(starData.name, { 'diameter': 1.0 }, scene)
 
// Load star texture files
var material = new BABYLON.StandardMaterial('mat', scene)
material.diffuseColor = new BABYLON.Color3(1, 0, 0)
// material.emissiveColor = new BABYLON.Color3(1.0, 0.0, 0.0)
// material.specularColor = new BABYLON.Color3(1.0, 0.0, 0.0)
// material.ambientColor = new BABYLON.Color3(1.0, 0.0, 0.0)
mesh.material = material
.
.
.

When the last line is commented out, this runs just fine, no errors.

When material assignment is un-commented, it throws the following error in the console of Chrome:

Quote

home/rook/Documents/Projects/testing/node_modules/babylonjs/dist/prev…:25221 Uncaught TypeError: engine.getColorWrite is not a function
    at Function.MaterialHelper.PrepareDefinesForFrameBoundValues (/home/rook/Documents/Projects/testing/node_modules/babylonjs/dist/prev…:25221)
    at StandardMaterial.isReadyForSubMesh (/home/rook/Documents/Projects/testing/node_modules/babylonjs/dist/prev…:31138)
    at Mesh.render (/home/rook/Documents/Projects/testing/node_modules/babylonjs/dist/prev…:22375)
    at SubMesh.render (/home/rook/Documents/Projects/testing/node_modules/babylonjs/dist/prev…:24285)
    at t.renderUnsorted (babylon.js:9)
    at t.render (babylon.js:9)
    at t.render (babylon.js:9)
    at r._renderForCamera (babylon.js:10)
    at r._processSubCameras (babylon.js:10)
    at r.render (babylon.js:10)

I think that this is very basic and simple code, and cannot figure out why this is throwing a Uncaught TypeError.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...