sasha240100 203b41b227 Update examples
- Basic/helloworld
- Basic/model

Former-commit-id: 0041355cec4c9bcf27584419849ced6489e69634
2016-10-26 19:35:44 +03:00

149 lines
3.4 KiB
JavaScript

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _globals = require('./globals');
var UTILS = _interopRequireWildcard(_globals);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
var world = new WHS.World(_extends({}, UTILS.$world));
var sphere = new WHS.Sphere({ // Create sphere comonent.
geometry: {
radius: 3,
widthSegments: 32,
heightSegments: 32
},
mass: 10, // Mass of physics object.
material: {
color: UTILS.$colors.mesh,
kind: 'lambert'
},
position: [0, 100, 0]
});
sphere.addTo(world);
UTILS.addPlane(world);
UTILS.addBasicLights(world);
world.start(); // Start animations and physics simulation.
world.setControls(WHS.orbitControls());
},{"./globals":2}],2:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.addBasicLights = addBasicLights;
exports.addPlane = addPlane;
exports.addBoxPlane = addBoxPlane;
var $world = exports.$world = {
stats: "fps", // fps, ms, mb or false if not need.
autoresize: "window",
gravity: { // Physic gravity.
x: 0,
y: -100,
z: 0
},
camera: {
z: 50, // Move camera.
y: 10
},
rendering: {
background: {
color: 0x162129
},
renderer: {
antialias: true
}
},
shadowmap: {
type: THREE.PCFSoftShadowMap
}
};
var $colors = exports.$colors = {
bg: 0x162129,
plane: 0x447F8B,
mesh: 0xF2F2F2
};
function addBasicLights(world) {
var intensity = arguments.length <= 1 || arguments[1] === undefined ? 0.5 : arguments[1];
var position = arguments.length <= 2 || arguments[2] === undefined ? [0, 10, 10] : arguments[2];
new WHS.PointLight({
light: {
intensity: intensity
},
shadowmap: {
fov: 90
},
position: [0, 10, 10]
}).addTo(world);
new WHS.AmbientLight({
light: {
intensity: 1 - intensity
}
}).addTo(world);
}
function addPlane(world) {
var size = arguments.length <= 1 || arguments[1] === undefined ? 100 : arguments[1];
new WHS.Plane({
geometry: {
width: size,
height: size
},
mass: 0,
material: {
color: 0x447F8B,
kind: 'phong'
},
rotation: {
x: -Math.PI / 2
}
}).addTo(world);
}
function addBoxPlane(world) {
var size = arguments.length <= 1 || arguments[1] === undefined ? 100 : arguments[1];
new WHS.Box({
geometry: {
width: size,
height: 1,
depth: size
},
mass: 0,
material: {
color: 0x447F8B,
kind: 'phong'
}
}).addTo(world);
}
},{}]},{},[1]);