PlayCanvas 介绍
一般来讲,游戏开发与web应用完全是两码事。但先试试,游戏世界的很多工具都可以被用于在网站中增加华丽界面。PlayCanvas就是一个基于WebGL的游戏引擎,结合了物理、光影、音效等工具用于创建一个复杂的界面。
示例代码:
// Create a PlayCanvas application 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 cube = new pc.fw.Entity(); app.context.systems.model.addComponent(cube, { type: "Box" }); // Create camera entity var camera = new pc.fw.Entity(); app.context.systems.camera.addComponent(camera, { clearColor: new pc.Color(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 app.context.root.addChild(cube); app.context.root.addChild(camera); app.context.root.addChild(light); // Set up initial positions and orientations camera.setPosition(0, 0, 3); light.setEulerAngles(45, 0, 0); // Register an update event app.on("update", function (deltaTime) { cube.rotate(10 * deltaTime, 20 * deltaTime, 30 * deltaTime); });
PlayCanvas 官网
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。