提交 www
This commit is contained in:
Generated
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
Generated
+4
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/2019nCoV.iml" filepath="$PROJECT_DIR$/.idea/2019nCoV.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+196
@@ -0,0 +1,196 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="379ce94e-8b54-4e06-8584-ec8f1cc09b79" name="Default Changelist" comment="" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/index.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="84">
|
||||
<caret line="4" column="33" selection-start-line="4" selection-start-column="33" selection-end-line="4" selection-end-column="33" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/bkp.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2079">
|
||||
<caret line="99" column="17" selection-start-line="99" selection-start-column="17" selection-end-line="99" selection-end-column="17" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>loader</find>
|
||||
<find>Controls</find>
|
||||
<find>OrbitControls</find>
|
||||
<find>camera</find>
|
||||
<find>initStats</find>
|
||||
<find>human</find>
|
||||
</findStrings>
|
||||
</component>
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/test1.html" />
|
||||
<option value="$PROJECT_DIR$/index.html" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="MacroExpansionManager">
|
||||
<option name="directoryName" value="YjjLpnxw" />
|
||||
</component>
|
||||
<component name="ProjectFrameBounds" extendedState="6">
|
||||
<option name="x" value="380" />
|
||||
<option name="y" value="134" />
|
||||
<option name="width" value="744" />
|
||||
<option name="height" value="456" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator proportions="" version="1">
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="ProjectPane" />
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="Scope" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||
<property name="go.gopath.indexing.explicitly.defined" value="true" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/../dragonfly" />
|
||||
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
|
||||
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="C:\Users\Cheney\projects\js\2019nCoV" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="379ce94e-8b54-4e06-8584-ec8f1cc09b79" name="Default Changelist" comment="" />
|
||||
<created>1580969553492</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1580969553492</updated>
|
||||
<workItem from="1580969556504" duration="4692000" />
|
||||
<workItem from="1581142261901" duration="389000" />
|
||||
<workItem from="1581145978472" duration="229000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="5310000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="-6" y="-6" width="1564" height="1093" extended-state="6" />
|
||||
<layout>
|
||||
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.2563081" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
<window_info id="Designer" order="2" />
|
||||
<window_info id="UI Designer" order="3" />
|
||||
<window_info id="Favorites" order="4" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" />
|
||||
<window_info anchor="bottom" id="Run" order="2" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
|
||||
<window_info anchor="bottom" id="Version Control" order="8" />
|
||||
<window_info anchor="bottom" id="Terminal" order="9" />
|
||||
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
|
||||
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||
<window_info anchor="right" id="Palette" order="3" />
|
||||
<window_info anchor="right" id="Cargo" order="4" />
|
||||
<window_info anchor="right" id="Maven" order="5" />
|
||||
<window_info anchor="right" id="Palette	" order="6" />
|
||||
<window_info anchor="right" id="SciView" order="7" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/three.js">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/ColladaLoader.js">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/stats.min.js">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/SVGRenderer.js">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/OrbitControls.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-67">
|
||||
<caret line="15" selection-start-line="15" selection-end-line="15" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/jquery.min.js">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/index.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="84">
|
||||
<caret line="4" column="33" selection-start-line="4" selection-start-column="33" selection-end-line="4" selection-end-column="33" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/bkp.html">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2079">
|
||||
<caret line="99" column="17" selection-start-line="99" selection-start-column="17" selection-end-line="99" selection-end-column="17" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
<state key="ProjectJDKs.UI">
|
||||
<settings>
|
||||
<last-edited>1.8</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
</states>
|
||||
</component>
|
||||
</project>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,508 @@
|
||||
/**
|
||||
* @author mrdoob / http://mrdoob.com/
|
||||
*/
|
||||
|
||||
THREE.SVGObject = function ( node ) {
|
||||
|
||||
THREE.Object3D.call( this );
|
||||
|
||||
this.node = node;
|
||||
|
||||
};
|
||||
|
||||
THREE.SVGObject.prototype = Object.create( THREE.Object3D.prototype );
|
||||
THREE.SVGObject.prototype.constructor = THREE.SVGObject;
|
||||
|
||||
THREE.SVGRenderer = function () {
|
||||
|
||||
console.log( 'THREE.SVGRenderer', THREE.REVISION );
|
||||
|
||||
var _this = this,
|
||||
_renderData, _elements, _lights,
|
||||
_projector = new THREE.Projector(),
|
||||
_svg = document.createElementNS( 'http://www.w3.org/2000/svg', 'svg' ),
|
||||
_svgWidth, _svgHeight, _svgWidthHalf, _svgHeightHalf,
|
||||
|
||||
_v1, _v2, _v3, _v4,
|
||||
|
||||
_clipBox = new THREE.Box2(),
|
||||
_elemBox = new THREE.Box2(),
|
||||
|
||||
_color = new THREE.Color(),
|
||||
_diffuseColor = new THREE.Color(),
|
||||
_ambientLight = new THREE.Color(),
|
||||
_directionalLights = new THREE.Color(),
|
||||
_pointLights = new THREE.Color(),
|
||||
_clearColor = new THREE.Color(),
|
||||
_clearAlpha = 1,
|
||||
|
||||
_vector3 = new THREE.Vector3(), // Needed for PointLight
|
||||
_centroid = new THREE.Vector3(),
|
||||
_normal = new THREE.Vector3(),
|
||||
_normalViewMatrix = new THREE.Matrix3(),
|
||||
|
||||
_viewMatrix = new THREE.Matrix4(),
|
||||
_viewProjectionMatrix = new THREE.Matrix4(),
|
||||
|
||||
_svgPathPool = [],
|
||||
_svgNode, _pathCount = 0,
|
||||
|
||||
_currentPath, _currentStyle,
|
||||
|
||||
_quality = 1, _precision = null;
|
||||
|
||||
this.domElement = _svg;
|
||||
|
||||
this.autoClear = true;
|
||||
this.sortObjects = true;
|
||||
this.sortElements = true;
|
||||
|
||||
this.info = {
|
||||
|
||||
render: {
|
||||
|
||||
vertices: 0,
|
||||
faces: 0
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.setQuality = function( quality ) {
|
||||
|
||||
switch ( quality ) {
|
||||
|
||||
case "high": _quality = 1; break;
|
||||
case "low": _quality = 0; break;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// WebGLRenderer compatibility
|
||||
|
||||
this.supportsVertexTextures = function () {};
|
||||
this.setFaceCulling = function () {};
|
||||
|
||||
this.setClearColor = function ( color, alpha ) {
|
||||
|
||||
_clearColor.set( color );
|
||||
_clearAlpha = alpha !== undefined ? alpha : 1;
|
||||
|
||||
};
|
||||
|
||||
this.setPixelRatio = function () {};
|
||||
|
||||
this.setSize = function( width, height ) {
|
||||
|
||||
_svgWidth = width; _svgHeight = height;
|
||||
_svgWidthHalf = _svgWidth / 2; _svgHeightHalf = _svgHeight / 2;
|
||||
|
||||
_svg.setAttribute( 'viewBox', ( - _svgWidthHalf ) + ' ' + ( - _svgHeightHalf ) + ' ' + _svgWidth + ' ' + _svgHeight );
|
||||
_svg.setAttribute( 'width', _svgWidth );
|
||||
_svg.setAttribute( 'height', _svgHeight );
|
||||
|
||||
_clipBox.min.set( - _svgWidthHalf, - _svgHeightHalf );
|
||||
_clipBox.max.set( _svgWidthHalf, _svgHeightHalf );
|
||||
|
||||
};
|
||||
|
||||
this.setPrecision = function ( precision ) {
|
||||
|
||||
_precision = precision;
|
||||
|
||||
};
|
||||
|
||||
function removeChildNodes() {
|
||||
|
||||
_pathCount = 0;
|
||||
|
||||
while ( _svg.childNodes.length > 0 ) {
|
||||
|
||||
_svg.removeChild( _svg.childNodes[ 0 ] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getSvgColor ( color, opacity ) {
|
||||
|
||||
var arg = Math.floor( color.r * 255 ) + ',' + Math.floor( color.g * 255 ) + ',' + Math.floor( color.b * 255 );
|
||||
|
||||
if ( opacity === undefined || opacity === 1 ) return 'rgb(' + arg + ')';
|
||||
|
||||
return 'rgb(' + arg + '); fill-opacity: ' + opacity;
|
||||
|
||||
}
|
||||
|
||||
function convert ( c ) {
|
||||
|
||||
return _precision !== null ? c.toFixed(_precision) : c;
|
||||
|
||||
}
|
||||
|
||||
this.clear = function () {
|
||||
|
||||
removeChildNodes();
|
||||
_svg.style.backgroundColor = getSvgColor( _clearColor, _clearAlpha );
|
||||
|
||||
};
|
||||
|
||||
this.render = function ( scene, camera ) {
|
||||
|
||||
if ( camera instanceof THREE.Camera === false ) {
|
||||
|
||||
console.error( 'THREE.SVGRenderer.render: camera is not an instance of THREE.Camera.' );
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
var background = scene.background;
|
||||
|
||||
if ( background && background.isColor ) {
|
||||
|
||||
removeChildNodes();
|
||||
_svg.style.backgroundColor = getSvgColor( background );
|
||||
|
||||
} else if ( this.autoClear === true ) {
|
||||
|
||||
this.clear();
|
||||
|
||||
}
|
||||
|
||||
_this.info.render.vertices = 0;
|
||||
_this.info.render.faces = 0;
|
||||
|
||||
_viewMatrix.copy( camera.matrixWorldInverse );
|
||||
_viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, _viewMatrix );
|
||||
|
||||
_renderData = _projector.projectScene( scene, camera, this.sortObjects, this.sortElements );
|
||||
_elements = _renderData.elements;
|
||||
_lights = _renderData.lights;
|
||||
|
||||
_normalViewMatrix.getNormalMatrix( camera.matrixWorldInverse );
|
||||
|
||||
calculateLights( _lights );
|
||||
|
||||
// reset accumulated path
|
||||
|
||||
_currentPath = '';
|
||||
_currentStyle = '';
|
||||
|
||||
for ( var e = 0, el = _elements.length; e < el; e ++ ) {
|
||||
|
||||
var element = _elements[ e ];
|
||||
var material = element.material;
|
||||
|
||||
if ( material === undefined || material.opacity === 0 ) continue;
|
||||
|
||||
_elemBox.makeEmpty();
|
||||
|
||||
if ( element instanceof THREE.RenderableSprite ) {
|
||||
|
||||
_v1 = element;
|
||||
_v1.x *= _svgWidthHalf; _v1.y *= - _svgHeightHalf;
|
||||
|
||||
renderSprite( _v1, element, material );
|
||||
|
||||
} else if ( element instanceof THREE.RenderableLine ) {
|
||||
|
||||
_v1 = element.v1; _v2 = element.v2;
|
||||
|
||||
_v1.positionScreen.x *= _svgWidthHalf; _v1.positionScreen.y *= - _svgHeightHalf;
|
||||
_v2.positionScreen.x *= _svgWidthHalf; _v2.positionScreen.y *= - _svgHeightHalf;
|
||||
|
||||
_elemBox.setFromPoints( [ _v1.positionScreen, _v2.positionScreen ] );
|
||||
|
||||
if ( _clipBox.intersectsBox( _elemBox ) === true ) {
|
||||
|
||||
renderLine( _v1, _v2, element, material );
|
||||
|
||||
}
|
||||
|
||||
} else if ( element instanceof THREE.RenderableFace ) {
|
||||
|
||||
_v1 = element.v1; _v2 = element.v2; _v3 = element.v3;
|
||||
|
||||
if ( _v1.positionScreen.z < - 1 || _v1.positionScreen.z > 1 ) continue;
|
||||
if ( _v2.positionScreen.z < - 1 || _v2.positionScreen.z > 1 ) continue;
|
||||
if ( _v3.positionScreen.z < - 1 || _v3.positionScreen.z > 1 ) continue;
|
||||
|
||||
_v1.positionScreen.x *= _svgWidthHalf; _v1.positionScreen.y *= - _svgHeightHalf;
|
||||
_v2.positionScreen.x *= _svgWidthHalf; _v2.positionScreen.y *= - _svgHeightHalf;
|
||||
_v3.positionScreen.x *= _svgWidthHalf; _v3.positionScreen.y *= - _svgHeightHalf;
|
||||
|
||||
_elemBox.setFromPoints( [
|
||||
_v1.positionScreen,
|
||||
_v2.positionScreen,
|
||||
_v3.positionScreen
|
||||
] );
|
||||
|
||||
if ( _clipBox.intersectsBox( _elemBox ) === true ) {
|
||||
|
||||
renderFace3( _v1, _v2, _v3, element, material );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
flushPath(); // just to flush last svg:path
|
||||
|
||||
scene.traverseVisible( function ( object ) {
|
||||
|
||||
if ( object instanceof THREE.SVGObject ) {
|
||||
|
||||
_vector3.setFromMatrixPosition( object.matrixWorld );
|
||||
_vector3.applyMatrix4( _viewProjectionMatrix );
|
||||
|
||||
var x = _vector3.x * _svgWidthHalf;
|
||||
var y = - _vector3.y * _svgHeightHalf;
|
||||
|
||||
var node = object.node;
|
||||
node.setAttribute( 'transform', 'translate(' + x + ',' + y + ')' );
|
||||
|
||||
_svg.appendChild( node );
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
};
|
||||
|
||||
function calculateLights( lights ) {
|
||||
|
||||
_ambientLight.setRGB( 0, 0, 0 );
|
||||
_directionalLights.setRGB( 0, 0, 0 );
|
||||
_pointLights.setRGB( 0, 0, 0 );
|
||||
|
||||
for ( var l = 0, ll = lights.length; l < ll; l ++ ) {
|
||||
|
||||
var light = lights[ l ];
|
||||
var lightColor = light.color;
|
||||
|
||||
if ( light instanceof THREE.AmbientLight ) {
|
||||
|
||||
_ambientLight.r += lightColor.r;
|
||||
_ambientLight.g += lightColor.g;
|
||||
_ambientLight.b += lightColor.b;
|
||||
|
||||
} else if ( light instanceof THREE.DirectionalLight ) {
|
||||
|
||||
_directionalLights.r += lightColor.r;
|
||||
_directionalLights.g += lightColor.g;
|
||||
_directionalLights.b += lightColor.b;
|
||||
|
||||
} else if ( light instanceof THREE.PointLight ) {
|
||||
|
||||
_pointLights.r += lightColor.r;
|
||||
_pointLights.g += lightColor.g;
|
||||
_pointLights.b += lightColor.b;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function calculateLight( lights, position, normal, color ) {
|
||||
|
||||
for ( var l = 0, ll = lights.length; l < ll; l ++ ) {
|
||||
|
||||
var light = lights[ l ];
|
||||
var lightColor = light.color;
|
||||
|
||||
if ( light instanceof THREE.DirectionalLight ) {
|
||||
|
||||
var lightPosition = _vector3.setFromMatrixPosition( light.matrixWorld ).normalize();
|
||||
|
||||
var amount = normal.dot( lightPosition );
|
||||
|
||||
if ( amount <= 0 ) continue;
|
||||
|
||||
amount *= light.intensity;
|
||||
|
||||
color.r += lightColor.r * amount;
|
||||
color.g += lightColor.g * amount;
|
||||
color.b += lightColor.b * amount;
|
||||
|
||||
} else if ( light instanceof THREE.PointLight ) {
|
||||
|
||||
var lightPosition = _vector3.setFromMatrixPosition( light.matrixWorld );
|
||||
|
||||
var amount = normal.dot( _vector3.subVectors( lightPosition, position ).normalize() );
|
||||
|
||||
if ( amount <= 0 ) continue;
|
||||
|
||||
amount *= light.distance == 0 ? 1 : 1 - Math.min( position.distanceTo( lightPosition ) / light.distance, 1 );
|
||||
|
||||
if ( amount == 0 ) continue;
|
||||
|
||||
amount *= light.intensity;
|
||||
|
||||
color.r += lightColor.r * amount;
|
||||
color.g += lightColor.g * amount;
|
||||
color.b += lightColor.b * amount;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function renderSprite( v1, element, material ) {
|
||||
|
||||
var scaleX = element.scale.x * _svgWidthHalf;
|
||||
var scaleY = element.scale.y * _svgHeightHalf;
|
||||
|
||||
if ( material.isPointsMaterial ) {
|
||||
scaleX *= material.size;
|
||||
scaleY *= material.size;
|
||||
}
|
||||
|
||||
var path = 'M' + convert( v1.x - scaleX * 0.5 ) + ',' + convert( v1.y - scaleY * 0.5 ) + 'h' + convert( scaleX ) + 'v' + convert( scaleY ) + 'h' + convert(-scaleX) + 'z';
|
||||
var style = "";
|
||||
|
||||
if ( material.isSpriteMaterial || material.isPointsMaterial ) {
|
||||
|
||||
style = 'fill:' + getSvgColor( material.color, material.opacity );
|
||||
|
||||
}
|
||||
|
||||
addPath( style, path );
|
||||
|
||||
}
|
||||
|
||||
function renderLine( v1, v2, element, material ) {
|
||||
|
||||
var path = 'M' + convert( v1.positionScreen.x ) + ',' + convert( v1.positionScreen.y ) + 'L' + convert( v2.positionScreen.x ) + ',' + convert( v2.positionScreen.y );
|
||||
|
||||
if ( material.isLineBasicMaterial ) {
|
||||
|
||||
var style = 'fill:none;stroke:' + getSvgColor( material.color, material.opacity ) + ';stroke-width:' + material.linewidth + ';stroke-linecap:' + material.linecap;
|
||||
|
||||
if ( material.isLineDashedMaterial ) {
|
||||
|
||||
style = style + ';stroke-dasharray:' + material.dashSize + "," + material.gapSize;
|
||||
|
||||
}
|
||||
|
||||
addPath( style, path );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function renderFace3( v1, v2, v3, element, material ) {
|
||||
|
||||
_this.info.render.vertices += 3;
|
||||
_this.info.render.faces ++;
|
||||
|
||||
var path = 'M' + convert( v1.positionScreen.x ) + ',' + convert( v1.positionScreen.y ) + 'L' + convert( v2.positionScreen.x ) + ',' + convert( v2.positionScreen.y ) + 'L' + convert( v3.positionScreen.x ) + ',' + convert( v3.positionScreen.y ) + 'z';
|
||||
var style = '';
|
||||
|
||||
if ( material instanceof THREE.MeshBasicMaterial ) {
|
||||
|
||||
_color.copy( material.color );
|
||||
|
||||
if ( material.vertexColors === THREE.FaceColors ) {
|
||||
|
||||
_color.multiply( element.color );
|
||||
|
||||
}
|
||||
|
||||
} else if ( material instanceof THREE.MeshLambertMaterial || material instanceof THREE.MeshPhongMaterial ) {
|
||||
|
||||
_diffuseColor.copy( material.color );
|
||||
|
||||
if ( material.vertexColors === THREE.FaceColors ) {
|
||||
|
||||
_diffuseColor.multiply( element.color );
|
||||
|
||||
}
|
||||
|
||||
_color.copy( _ambientLight );
|
||||
|
||||
_centroid.copy( v1.positionWorld ).add( v2.positionWorld ).add( v3.positionWorld ).divideScalar( 3 );
|
||||
|
||||
calculateLight( _lights, _centroid, element.normalModel, _color );
|
||||
|
||||
_color.multiply( _diffuseColor ).add( material.emissive );
|
||||
|
||||
} else if ( material instanceof THREE.MeshNormalMaterial ) {
|
||||
|
||||
_normal.copy( element.normalModel ).applyMatrix3( _normalViewMatrix );
|
||||
|
||||
_color.setRGB( _normal.x, _normal.y, _normal.z ).multiplyScalar( 0.5 ).addScalar( 0.5 );
|
||||
|
||||
}
|
||||
|
||||
if ( material.wireframe ) {
|
||||
|
||||
style = 'fill:none;stroke:' + getSvgColor( _color, material.opacity ) + ';stroke-width:' + material.wireframeLinewidth + ';stroke-linecap:' + material.wireframeLinecap + ';stroke-linejoin:' + material.wireframeLinejoin;
|
||||
|
||||
} else {
|
||||
|
||||
style = 'fill:' + getSvgColor( _color, material.opacity );
|
||||
|
||||
}
|
||||
|
||||
addPath( style, path );
|
||||
|
||||
}
|
||||
|
||||
function addPath ( style, path ) {
|
||||
|
||||
if ( _currentStyle === style ) {
|
||||
|
||||
_currentPath += path
|
||||
|
||||
} else {
|
||||
|
||||
flushPath();
|
||||
|
||||
_currentStyle = style;
|
||||
_currentPath = path;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function flushPath() {
|
||||
|
||||
if ( _currentPath ) {
|
||||
|
||||
_svgNode = getPathNode( _pathCount ++ );
|
||||
_svgNode.setAttribute( 'd', _currentPath );
|
||||
_svgNode.setAttribute( 'style', _currentStyle );
|
||||
_svg.appendChild( _svgNode );
|
||||
|
||||
}
|
||||
|
||||
_currentPath = '';
|
||||
_currentStyle = '';
|
||||
|
||||
}
|
||||
|
||||
function getPathNode( id ) {
|
||||
|
||||
if ( _svgPathPool[ id ] == null ) {
|
||||
|
||||
_svgPathPool[ id ] = document.createElementNS( 'http://www.w3.org/2000/svg', 'path' );
|
||||
|
||||
if ( _quality == 0 ) {
|
||||
|
||||
_svgPathPool[ id ].setAttribute( 'shape-rendering', 'crispEdges' ); //optimizeSpeed
|
||||
|
||||
}
|
||||
|
||||
return _svgPathPool[ id ];
|
||||
|
||||
}
|
||||
|
||||
return _svgPathPool[ id ];
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
@@ -0,0 +1,136 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>2019nCov draw by Cheney</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
canvas {
|
||||
width: 100%;
|
||||
height: 100%
|
||||
}
|
||||
</style>
|
||||
<script src="./three.js" type="text/javascript"></script>
|
||||
<script src="./ColladaLoader.js" type="text/javascript"></script>
|
||||
<script src="./OrbitControls.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var scene, camera, renderer, daeModel;
|
||||
// 获得可见区域宽度
|
||||
var width = document.documentElement.clientWidth;
|
||||
// 获得可见区域的高度
|
||||
var height = document.documentElement.clientHeight;
|
||||
//初始化场景
|
||||
function initScene() {
|
||||
scene = new THREE.Scene();
|
||||
}
|
||||
|
||||
//初始化摄像机
|
||||
function initcamera() {
|
||||
aspect = width / height;
|
||||
D = 8;
|
||||
camera = new THREE.OrthographicCamera(-D * aspect, D * aspect, D, -D, 1, 1000);
|
||||
//camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight,0.1,200)
|
||||
camera.position.set(300, -300, 300);
|
||||
camera.lookAt(new THREE.Vector3(0, 0, 0));
|
||||
camera.up.x = 0;
|
||||
camera.up.y = 0;
|
||||
camera.up.z = 1;
|
||||
//camera.rotation.z = 1 / 6 * Math.PI;
|
||||
//camera.rotation.z = 5/6*Math.PI;
|
||||
}
|
||||
|
||||
function initthree() {
|
||||
renderer = new THREE.WebGLRenderer();
|
||||
renderer.setSize(width, height);
|
||||
renderer.setClearColor(0xffffff);
|
||||
document.body.appendChild(renderer.domElement);
|
||||
/*
|
||||
var spotLight = new THREE.SpotLight( 0xffffff );
|
||||
spotLight.position.set( 100, 1000, 100 );
|
||||
|
||||
spotLight.castShadow = true;
|
||||
|
||||
spotLight.shadow.mapSize.width = 1024;
|
||||
spotLight.shadow.mapSize.height = 1024;
|
||||
|
||||
spotLight.shadow.camera.near = 500;
|
||||
spotLight.shadow.camera.far = 4000;
|
||||
spotLight.shadow.camera.fov = 30;
|
||||
|
||||
scene.add( spotLight );
|
||||
*/
|
||||
}
|
||||
|
||||
function initlight() {
|
||||
var light = new THREE.DirectionalLight(0xffffff, 2);
|
||||
light.position.set(300, -300, 200);
|
||||
scene.add(light);
|
||||
|
||||
|
||||
var ambientLight = new THREE.AmbientLight( 0xffffff, 0.2 );
|
||||
scene.add( ambientLight );
|
||||
|
||||
var pointLight = new THREE.PointLight( 0xffffff, 0.8 );
|
||||
camera.add( pointLight );
|
||||
}
|
||||
|
||||
function LoadModel() {
|
||||
var loader = new THREE.ColladaLoader();
|
||||
loader.load("./model.dae", function (collada) {
|
||||
|
||||
console.log("collada", collada)
|
||||
|
||||
daeModel = collada.scene;
|
||||
daeModel.scale.set(5, 5, 5);
|
||||
daeModel.position.set(0, 0, 0);
|
||||
scene.add(daeModel);
|
||||
//参考坐标轴
|
||||
var axisHelper = new THREE.AxisHelper(500);
|
||||
scene.add(axisHelper);
|
||||
},
|
||||
function (xhr) {
|
||||
console.log((xhr.loaded / xhr.total * 100) + "% loaded");
|
||||
});
|
||||
}
|
||||
|
||||
//初始化渲染器
|
||||
function render() {
|
||||
requestAnimationFrame(render);
|
||||
|
||||
renderer.clear();
|
||||
|
||||
renderer.render(scene, camera);
|
||||
//if( daeModel ){
|
||||
// daeModel.rotation.z++;
|
||||
//}
|
||||
}
|
||||
|
||||
var Controls;
|
||||
|
||||
// 初始化控制器
|
||||
function initControls() {
|
||||
Controls = new THREE.OrbitControls(camera);
|
||||
}
|
||||
|
||||
function startGame() {
|
||||
console.log('Load Model started...');
|
||||
initScene();
|
||||
initcamera();
|
||||
initthree();
|
||||
initlight();
|
||||
LoadModel();
|
||||
render();
|
||||
initControls();
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="startGame()" onresize="startGame()">
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,217 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>2019nCov draw by Cheney</title>
|
||||
<script type="text/javascript" src="./three.js"></script>
|
||||
<script src="./ColladaLoader.js" type="text/javascript"></script>
|
||||
<script src="./OrbitControls.js" type="text/javascript"></script>
|
||||
<script src="./jquery.min.js"></script>
|
||||
<script type="text/javascript" src="./stats.min.js"></script>
|
||||
<script type="text/javascript" src="./SVGRenderer.js"></script>
|
||||
|
||||
<script id="vertexShader" type="x-shader/x-vertex">
|
||||
uniform vec3 viewVector;
|
||||
uniform float c;
|
||||
uniform float p;
|
||||
varying float intensity;
|
||||
void main()
|
||||
{
|
||||
vec3 vNormal = normalize( normalMatrix * normal );
|
||||
vec3 vNormel = normalize( normalMatrix * viewVector );
|
||||
intensity = pow( c - dot(vNormal, vNormel), p );
|
||||
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- fragment shader a.k.a. pixel shader -->
|
||||
<script id="fragmentShader" type="x-shader/x-vertex">
|
||||
uniform vec3 glowColor;
|
||||
varying float intensity;
|
||||
void main()
|
||||
{
|
||||
vec3 glow = glowColor * intensity;
|
||||
gl_FragColor = vec4( glow, 1.0 );
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
/* set margin to 0 and overflow to hidden, to go fullscreen */
|
||||
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="Stats-output">
|
||||
</div>
|
||||
<!-- Div which will hold the Output -->
|
||||
<div id="WebGL-output">
|
||||
</div>
|
||||
|
||||
<!-- Javascript code that runs our Three.js examples -->
|
||||
<script type="text/javascript">
|
||||
// once everything is loaded, we run our Three.js stuff.
|
||||
$(function () {
|
||||
var mouseX = 0, mouseY = 0;
|
||||
var human;
|
||||
camstep = 0;
|
||||
|
||||
var stats = initStats();
|
||||
|
||||
// create a scene, that will hold all our elements such as objects, cameras and lights.
|
||||
var scene = new THREE.Scene();
|
||||
|
||||
// create a camera, which defines where we're looking at.
|
||||
var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
|
||||
|
||||
// create a render and set the size
|
||||
var renderer = new THREE.WebGLRenderer({antialias: true, alpha: true});
|
||||
|
||||
renderer.setClearColor(0x000000, 1.0);
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
renderer.shadowMapEnabled = true;
|
||||
renderer.shadowMapType = THREE.PCFShadowMap;
|
||||
|
||||
|
||||
materialCameraPosition = camera.position.clone();
|
||||
materialCameraPosition.z += 10;
|
||||
|
||||
// position and point the camera to the center of the scene
|
||||
camera.position.x = -10;
|
||||
camera.position.y = 0;
|
||||
camera.position.z = 15;
|
||||
lookAt = scene.position;
|
||||
lookAt.y = 15;
|
||||
camera.lookAt(lookAt);
|
||||
|
||||
// add subtle ambient lighting
|
||||
var ambientLight = new THREE.AmbientLight(0x0c0c0c);
|
||||
//scene.add(ambientLight);
|
||||
|
||||
|
||||
// add the output of the renderer to the html element
|
||||
$("#WebGL-output").append(renderer.domElement);
|
||||
|
||||
var customMaterial = new THREE.ShaderMaterial(
|
||||
{
|
||||
uniforms: {
|
||||
"c": { type: "f", value: 1.0 },
|
||||
"p": { type: "f", value: 3 },
|
||||
glowColor: { type: "c", value: new THREE.Color(0x84ccff) },
|
||||
viewVector: { type: "v3", value: materialCameraPosition }
|
||||
},
|
||||
vertexShader: document.getElementById('vertexShader').textContent,
|
||||
fragmentShader: document.getElementById('fragmentShader').textContent,
|
||||
side: THREE.FrontSide,
|
||||
blending: THREE.AdditiveBlending,
|
||||
transparent: true,
|
||||
opacity: 0.1,
|
||||
depthWrite: false
|
||||
});
|
||||
|
||||
var manager = new THREE.LoadingManager();
|
||||
manager.onProgress = function (item, loaded, total) {
|
||||
console.log(item, loaded, total);
|
||||
};
|
||||
// var loader = new THREE.OBJLoader(manager);
|
||||
// loader.load('body_anatomy3.obj', function (object) {
|
||||
// console.log(object);
|
||||
// object.traverse(function (child) {
|
||||
// if (child instanceof THREE.Mesh) {
|
||||
// console.log(child);
|
||||
// child.material = customMaterial;
|
||||
// }
|
||||
// });
|
||||
// object.position.y = 4;
|
||||
// object.scale.x = 0.01;
|
||||
// object.scale.y = 0.01;
|
||||
// object.scale.z = 0.01;
|
||||
// human = object;
|
||||
// scene.add(human);
|
||||
// });
|
||||
var loader = new THREE.ColladaLoader();
|
||||
loader.load("./model.dae", function (collada) {
|
||||
|
||||
console.log("collada", collada)
|
||||
collada.scene.children[0].material = customMaterial;
|
||||
daeModel = collada.scene;
|
||||
daeModel.scale.set(5, 5, 5);
|
||||
daeModel.position.set(0, 0, 0);
|
||||
scene.add(daeModel);
|
||||
//参考坐标轴
|
||||
var axisHelper = new THREE.AxisHelper(500);
|
||||
scene.add(axisHelper);
|
||||
},
|
||||
function (xhr) {
|
||||
console.log((xhr.loaded / xhr.total * 100) + "% loaded");
|
||||
});
|
||||
|
||||
// call the render function
|
||||
var step = 0;
|
||||
render();
|
||||
|
||||
function render() {
|
||||
stats.update();
|
||||
|
||||
// camstep += 0.02;
|
||||
//
|
||||
// camera.position.x = -20 * (Math.cos(camstep));
|
||||
// camera.position.z = (20 * (Math.sin(camstep)));
|
||||
// camera.position.y = 20;
|
||||
|
||||
camera.lookAt(lookAt);
|
||||
//
|
||||
// if (human) {
|
||||
// //human.rotation.y += 0.02;
|
||||
// materialCameraPosition = camera.position.clone();
|
||||
// materialCameraPosition.z += 10;
|
||||
// human.traverse(function (child) {
|
||||
// if (child instanceof THREE.Mesh) {
|
||||
// //console.log(child.material.uniforms.viewVector);
|
||||
// child.material.uniforms.viewVector.value =
|
||||
// new THREE.Vector3().subVectors(camera.position, human.position);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
//sphere.material.uniforms.viewVector.value = new THREE.Vector3().subVectors(camera.position, sphere.position);
|
||||
|
||||
// render using requestAnimationFrame
|
||||
requestAnimationFrame(render);
|
||||
renderer.render(scene, camera);
|
||||
}
|
||||
|
||||
function initStats() {
|
||||
|
||||
var stats = new Stats();
|
||||
|
||||
stats.setMode(0); // 0: fps, 1: ms
|
||||
|
||||
// Align top-left
|
||||
stats.domElement.style.position = 'absolute';
|
||||
stats.domElement.style.left = '0px';
|
||||
stats.domElement.style.top = '0px';
|
||||
|
||||
$("#Stats-output").append(stats.domElement);
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
var Controls;
|
||||
|
||||
// 初始化控制器
|
||||
function initControls() {
|
||||
Controls = new THREE.OrbitControls(camera);
|
||||
}
|
||||
initControls()
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Vendored
+4
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
// stats.js - http://github.com/mrdoob/stats.js
|
||||
var Stats=function(){function h(a){c.appendChild(a.dom);return a}function k(a){for(var d=0;d<c.children.length;d++)c.children[d].style.display=d===a?"block":"none";l=a}var l=0,c=document.createElement("div");c.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000";c.addEventListener("click",function(a){a.preventDefault();k(++l%c.children.length)},!1);var g=(performance||Date).now(),e=g,a=0,r=h(new Stats.Panel("FPS","#0ff","#002")),f=h(new Stats.Panel("MS","#0f0","#020"));
|
||||
if(self.performance&&self.performance.memory)var t=h(new Stats.Panel("MB","#f08","#201"));k(0);return{REVISION:16,dom:c,addPanel:h,showPanel:k,begin:function(){g=(performance||Date).now()},end:function(){a++;var c=(performance||Date).now();f.update(c-g,200);if(c>e+1E3&&(r.update(1E3*a/(c-e),100),e=c,a=0,t)){var d=performance.memory;t.update(d.usedJSHeapSize/1048576,d.jsHeapSizeLimit/1048576)}return c},update:function(){g=this.end()},domElement:c,setMode:k}};
|
||||
Stats.Panel=function(h,k,l){var c=Infinity,g=0,e=Math.round,a=e(window.devicePixelRatio||1),r=80*a,f=48*a,t=3*a,u=2*a,d=3*a,m=15*a,n=74*a,p=30*a,q=document.createElement("canvas");q.width=r;q.height=f;q.style.cssText="width:80px;height:48px";var b=q.getContext("2d");b.font="bold "+9*a+"px Helvetica,Arial,sans-serif";b.textBaseline="top";b.fillStyle=l;b.fillRect(0,0,r,f);b.fillStyle=k;b.fillText(h,t,u);b.fillRect(d,m,n,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d,m,n,p);return{dom:q,update:function(f,
|
||||
v){c=Math.min(c,f);g=Math.max(g,f);b.fillStyle=l;b.globalAlpha=1;b.fillRect(0,0,r,m);b.fillStyle=k;b.fillText(e(f)+" "+h+" ("+e(c)+"-"+e(g)+")",t,u);b.drawImage(q,d+a,m,n-a,p,d,m,n-a,p);b.fillRect(d+n-a,m,a,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d+n-a,m,a,e((1-f/v)*p))}}};"object"===typeof module&&(module.exports=Stats);
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user