mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
101 lines
2.7 KiB
HTML
101 lines
2.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<title>spec-scroll-view</title>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
|
|
<style>
|
|
body {
|
|
background-color: #333;
|
|
margin: 0px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.fit {
|
|
position: absolute;
|
|
top: 0;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body class="fit">
|
|
<canvas id="canvas" tabindex="-1" class="fit" width="256" height="256">
|
|
<img name="testImg" src="cubetexture.png" />
|
|
</canvas>
|
|
|
|
<script src="../bin/cocos-3d.dev.js"></script>
|
|
<!-- <script src="./loadScene.js"></script> -->
|
|
<script>
|
|
function onStart() {
|
|
const $body = document.body;
|
|
const bcr = $body.getBoundingClientRect();
|
|
// cc.view.setCanvasSize(bcr.width, bcr.height);
|
|
window.addEventListener('resize', () => {
|
|
const bcr = $body.getBoundingClientRect();
|
|
cc.view.setCanvasSize(bcr.width, bcr.height);
|
|
});
|
|
|
|
let root = cc.director.root;
|
|
let scene = root.createScene({
|
|
name: "testScene",
|
|
});
|
|
|
|
let mainWindow = root.mainWindow;
|
|
|
|
let view = root.createView({
|
|
name: "defaultView",
|
|
window: mainWindow,
|
|
//priority: cc.RenderViewPriority.GENERAL,
|
|
priority: 100,
|
|
width: mainWindow.width,
|
|
height: mainWindow.height,
|
|
});
|
|
view.attach(scene.mainCamera);
|
|
|
|
let camera = scene.mainCamera;
|
|
camera.position = { x: 0.0, y: 0.0, z: 3.0 };
|
|
camera.direction = { x: 0.0, y: 0.0, z: -1.0 };
|
|
camera.update();
|
|
|
|
|
|
//todo initialization
|
|
/*
|
|
let scene = new cc.Scene();
|
|
let node = new cc.Node();
|
|
scene.addChild(node);
|
|
node.addComponent('cc.CameraComponent');
|
|
let modelNode = new cc.Node();
|
|
modelNode.setPosition(0, 0, -10);
|
|
scene.addChild(modelNode);
|
|
let model = modelNode.addComponent('cc.ModelComponent');
|
|
*/
|
|
|
|
// init mesh
|
|
//model.mesh = cc.utils.createMesh(cc.game._renderContext, cc.primitives.box());
|
|
/**
|
|
// init effect
|
|
let mtl = new cc.Material();
|
|
let color = cc.color('#B58C42');
|
|
mtl.effectName = cc.game._builtins['builtin-effect-unlit'];
|
|
mtl.define('USE_COLOR', true);
|
|
mtl.setProperty('color', color);
|
|
/**
|
|
mtl.effect = cc.game._builtins['builtin-effect-phong'];
|
|
mtl.setProperty('diffuseColor', color);
|
|
/**
|
|
mtl.effect = cc.game._builtins['builtin-effect-pbr'];
|
|
mtl.define('USE_EMISSIVE', true);
|
|
mtl.setProperty('emissive', color);
|
|
/**/
|
|
// model.material = mtl;
|
|
//cc.director.runSceneImmediate(scene);
|
|
}
|
|
cc.game.run({ id: 'canvas' }, onStart);
|
|
</script>
|
|
</body>
|
|
|
|
</html> |