// Create a PlayCanvas application "use strict"; var canvas = document.getElementById("application-canvas"); var app = new pc.fw.Application(canvas, {}); app.start(); // Fill the available space at full resolution app.setCanvasFillMode(pc.fw.FillMode.FILL_WINDOW); app.setCanvasResolution(pc.fw.ResolutionMode.AUTO); // Create box entity var e, c = 1000, es = []; for (var i = 0; i < c; i++) { e = new pc.fw.Entity(); es.push(e); e.setLocalPosition(Math.random() * 10 - 5, Math.random() * 10 - 5, Math.random() * 10 - 5); app.context.systems.model.addComponent(es[i], { type: "box", }); }; // Create camera entity var cam = new pc.fw.Entity(); app.context.systems.camera.addComponent(cam, { clearColor: [0.1,0.1,0.1] }); // Create directional light entity var light = new pc.fw.Entity(); app.context.systems.light.addComponent(light); // Add to hierarchy for (var i = 0; i < es.length; i++) { app.context.root.addChild(es[i]); }; app.context.root.addChild(cam); app.context.root.addChild(light); // Set up position and orientation cam.setLocalPosition(0, 0, 20); light.setEulerAngles(45, 45, 0); var time = window.performance.now(), newTime = 0; // Register an update event app.on("update", function (dt) { var newTime = window.performance.now(); document.title = Math.round(1000 / (newTime - time)); time = newTime; var angles = es[0].getEulerAngles(); for (var i = 0; i < c; i++) { es[i].setEulerAngles(angles.x + 30*dt, 0, 0); }; });