Skip to content

Commit

Permalink
Merge pull request #547 from redcamel/dev
Browse files Browse the repository at this point in the history
-
  • Loading branch information
redcamel authored Feb 28, 2019
2 parents a764aaf + 08b8cb7 commit a9864bc
Show file tree
Hide file tree
Showing 9 changed files with 358 additions and 195 deletions.
24 changes: 20 additions & 4 deletions example/baseTestUI.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

var baseTestUI = function (redGL, width) {
// var getQueryParam = function(param) {
// var found;
Expand All @@ -11,10 +10,23 @@ var baseTestUI = function (redGL, width) {
// };
// console.log(getQueryParam('name'))
document.body.appendChild(testBt = document.createElement('div'));
testBt.innerHTML = 'created by Redcamel'
testBt.innerHTML = 'created by Redcamel'
testBt.style.cssText = "position: fixed;top:40px;padding:0px;left:15px;font-size:11px; color:#fff;border:0;outline:none;"
//

// Global site tag (gtag.js) - Google Analytics
var t0 = document.createElement('script');
t0.setAttribute('async', '');
t0.setAttribute('src', 'https://www.googletagmanager.com/gtag/js?id=UA-134079611-1');
document.head.appendChild(t0)
//
t0 = document.createElement('script');
t0.innerHTML = 'window.dataLayer = window.dataLayer || [];';
t0.innerHTML += 'function gtag(){dataLayer.push(arguments);}';
t0.innerHTML += 'gtag(\'js\', new Date());';
t0.innerHTML += 'gtag(\'config\', \'UA-134079611-1\');';
document.head.appendChild(t0);


baseTestUI.makeBaseUI();
this['gui'] = new dat.GUI({name: 'RedGL Test UI'});
Expand Down Expand Up @@ -95,7 +107,7 @@ baseTestUI.makeBaseUI = function () {
document.head.appendChild(t0);
makeSourceView();
};
baseTestUI.exampleList = [
baseTestUI.exampleList = [
{
key: 'RedGL',
list: [
Expand All @@ -110,6 +122,10 @@ baseTestUI.exampleList = [
{
key: 'RedView',
href: 'etc/RedView.html'
},
{
key: 'Multi RedGL Instance',
href: 'etc/multiRedGLInstance.html'
}
]
},
Expand Down Expand Up @@ -540,7 +556,7 @@ var makeItem = function (list, depth) {

})
}
baseTestUI.itemList= []
baseTestUI.itemList = []
makeItem(baseTestUI.exampleList)
baseTestUI.prototype = {
initRedGL: function (open) {
Expand Down
104 changes: 104 additions & 0 deletions example/etc/multiRedGLInstance.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<html>

<head>
<meta charset="UTF-8">
<title>RedGL - Multi RedGL Instance</title>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi"
/>
<link rel="stylesheet" href="../example.css">
<script src="../dat.gui.min.js"></script>
<script src="../baseTestUI.js"></script>
<script src="../../release/RedGL.min.js"></script>
</head>

<body>
<script id='testSource'>
var testUI;
testUI = function (redGL) {
var gui = new baseTestUI(redGL);
}
var assetPath = '../../asset/'
var test = []

var MAX = 6
var i = MAX

while (i--) {
var canvas;
canvas = document.createElement('canvas');
document.body.appendChild(canvas);
test.push(canvas)
}


test.forEach(function (tCanvas, index) {
RedGL(tCanvas, function (v) {
if (v) {
if (index == 0) testUI(this)
//TODO 코드정리
console.log('초기화 성공!');
this.setSize((100 / MAX) + '%', '100%')
var tWorld, tView, tScene, tController, tRenderer;
var setBase = function (redGL) {
// 월드 생성
redGL['world'] = tWorld = RedWorld();
// 씬 생성
tScene = RedScene(redGL);
// 카메라 생성
tController = RedCamera(this);
// tController.pan = 0;
// tController.tilt = -45;
// 렌더러 생성

// 뷰생성 및 적용
tView = RedView('HelloRedGL' + index, redGL, tScene, tController);

tWorld.addView(tView);
// 그리드 설정
tScene['grid'] = RedGrid(redGL);
// 렌더 디버거 활성화
// tRenderer.setDebugButton();
// 렌더시작

var testDLight;
testDLight = RedDirectionalLight(redGL)
testDLight.x = 3
testDLight.y = 2
testDLight.z = 3
// testDLight.debug = true
tScene.addLight(testDLight)

tRenderer = RedRenderer();
tRenderer.start(redGL, function (time) {
tController.x = Math.sin(time / 1500) * 10
tController.z = Math.cos(time / 1500) * 10
tController.y = Math.tan(time / 1500) * 10
tController.lookAt(0, 0, 0)
});


};
setBase(this);
var tMesh;
console.log(this)
tMesh = RedMesh(this, RedBox(this), RedStandardMaterial(this, RedBitmapTexture(this, assetPath + 'UV_Grid_Sm.jpg')))
tScene.addChild(tMesh)

tMesh = RedMesh(this, RedBox(this), RedStandardMaterial(this, RedBitmapTexture(this, assetPath + 'crate.png')))
tMesh.x = 1
tScene.addChild(tMesh)


} else {
console.log('초기화 실패!')
}
});
})

</script>
</body>

</html>
1 change: 0 additions & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@

gtag('config', 'UA-134079611-1');
</script>

</body>

</html>
Binary file added example/thumb/Multi RedGL Instance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a9864bc

Please sign in to comment.