gC is not a constructor

Hello,

I am getting an error and was able to reproduce it in the playground. I couldn’t figure out how to share my playground directly, so here is the code that went in it:


export const createScene = function () {
// This creates a basic Babylon Scene object (non-mesh)
var scene = new BABYLON.Scene(engine);

// This creates and positions a free camera (non-mesh)
var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);

// This targets the camera to scene origin
camera.setTarget(BABYLON.Vector3.Zero());

// This attaches the camera to the canvas
camera.attachControl(canvas, true);

// This creates a light, aiming 0,1,0 - to the sky (non-mesh)
var light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene);

// Default intensity is 1. Let's dim the light a small amount
light.intensity = 0.7;

// Our built-in 'sphere' shape.

const OD = 3
const StrandChamfer = 0.2;
const StrandChamferDegree = 15;
const LACR = 0.3;
const ODRadius = OD / 2;
const ChamferRadius = ODRadius - StrandChamfer * Math.cos(StrandChamferDegree * Math.PI / 180.0);	// Chamfer Radius
const ChamferWidth = StrandChamfer * Math.sin(StrandChamferDegree * Math.PI / 180.0);	// Chamfer Radius
const BetweenChamfers = StrandThickness - 2 * ChamferWidth;

// Define the shape to be rotated
//X and why are kinda flipped in the 3d model from how you would like it to be because the lathe rotates around the y axis
const StrandsShape = [
new BABYLON.Vector3(0, -LACR / 2, 0),
new BABYLON.Vector3(ChamferRadius, -LACR / 2, 0),
new BABYLON.Vector3(ODRadius, -LACR / 2 + ChamferWidth, 0)
];
let yPos = -LACR / 2 + ChamferWidth + BetweenChamfers;
StrandsShape.push(new BABYLON.Vector3(ODRadius, LACR / 2 - ChamferWidth, 0));
StrandsShape.push(new BABYLON.Vector3(ChamferRadius, LACR / 2, 0));
StrandsShape.push(new BABYLON.Vector3(0, LACR / 2, 0));

// Create the lathe
const ODMesh = BABYLON.MeshBuilder.CreateLathe(“lathe”, { shape: StrandsShape, sideOrientation: BABYLON.Mesh.DOUBLESIDE });//radius: 1,
const ODCSG = BABYLON.CSG2.FromMesh(ODMesh);
ODMesh.dispose();
return scene;
};

it is throwing the error on this line towards the end:
const ODCSG = BABYLON.CSG2.FromMesh(ODMesh);

appreciate any help with this.

Zach

You are just missing the CSG2 initialization, line 43 added (also you must make the function async on line 1). PG below:

For sharing playgrounds, you can click on save and the copy/paste the URL:

Awesome! Thank you so much, that worked.