/** * Returns appropriate representation of that media version in an html tag, including attributes for display * * @param string $field field name * @param string $version version of the media file, as defined in media_processing.conf * @param string $name name attribute of the img tag * @param string $vspace vspace attribute of the img tag - note: deprecated in HTML 4.01, not supported in XHTML 1.0 Strict * @param string $hspace hspace attribute of the img tag - note: deprecated in HTML 4.01, not supported in XHTML 1.0 Strict * @param string $alt alt attribute of the img tag * @param int $border border attribute of the img tag - note: deprecated in HTML 4.01, not supported in XHTML 1.0 Strict * @param string $usemap usemap attribute of the img tag * @param int $align align attribute of the img tag - note: deprecated in HTML 4.01, not supported in XHTML 1.0 Strict * @return string html tag */ public function getMediaTag($ps_field, $ps_version, $pa_options = null) { if (!is_array($va_media_info = $this->getMediaInfo($ps_field))) { return null; } if (!is_array($va_media_info[$ps_version])) { return null; } # # Use icon # if (isset($va_media_info[$ps_version]['USE_ICON']) && ($vs_icon_code = $va_media_info[$ps_version]['USE_ICON'])) { return caGetDefaultMediaIconTag($vs_icon_code, $va_media_info[$ps_version]['WIDTH'], $va_media_info[$ps_version]['HEIGHT']); } # # Is this version queued for processing? # if (isset($va_media_info[$ps_version]["QUEUED"]) && $va_media_info[$ps_version]["QUEUED"]) { return $va_media_info[$ps_version]["QUEUED_MESSAGE"]; } $url = $this->getMediaUrl($ps_field, $ps_version, isset($pa_options["page"]) ? $pa_options["page"] : null); $m = new Media(); $o_vol = new MediaVolumes(); $va_volume = $o_vol->getVolumeInformation($va_media_info[$ps_version]['VOLUME']); return $m->htmlTag($va_media_info[$ps_version]["MIMETYPE"], $url, $va_media_info[$ps_version]["PROPERTIES"], $pa_options, $va_volume); }
public function htmlTag($ps_url, $pa_properties, $pa_options = null, $pa_volume_info = null) { AssetLoadManager::register('3dmodels'); if (!is_array($pa_options)) { $pa_options = array(); } $vn_width = isset($pa_options["viewer_width"]) && $pa_options["viewer_width"] > 0 ? $pa_options["viewer_width"] : 820; $vn_height = isset($pa_options["viewer_height"]) && $pa_options["viewer_height"] > 0 ? $pa_options["viewer_height"] : 520; $vs_id = isset($pa_options["id"]) && $pa_options["id"] ? $pa_options["id"] : "mesh_canvas"; $vs_bgcolor = isset($pa_options["background_color"]) && $pa_options["background_color"] ? preg_replace("![^A-Fa-f0-9]+!", "", $pa_options["background_color"]) : "CCCCCC"; $vs_progress_id = isset($pa_options["progress_id"]) && $pa_options["progress_id"] ? $pa_options["progress_id"] : "caMediaOverlayProgress"; $vn_progress_total_filesize = isset($pa_options["progress_total_filesize"]) && $pa_options["progress_total_filesize"] > 0 ? $pa_options["progress_total_filesize"] : 0; if (in_array($pa_properties['mimetype'], array("application/ply", "application/stl", "application/ctm"))) { ob_start(); ?> <div id="viewer"></div> <script type="text/javascript"> var container, stats; var camera, cameraTarget, scene, renderer; var total_filesize = <?php print $vn_progress_total_filesize; ?> ; init(); animate(); function init() { container = document.getElementById('viewer'); camera = new THREE.PerspectiveCamera( 35, window.innerWidth / window.innerHeight, 1, 150 ); camera.position.set( 3, 0.15, 3 ); cameraTarget = new THREE.Vector3( 0, -0.25, 0 ); scene = new THREE.Scene(); scene.add(camera); // ASCII file <?php switch ($pa_properties['mimetype']) { case 'application/stl': ?> var loader = new THREE.STLLoader(); <?php break; case 'application/ply': ?> var loader = new THREE.PLYLoader(); <?php break; case 'application/ctm': ?> var loader = new THREE.CTMLoader(); <?php break; } ?> function postLoad ( event ) { var geometry = event; if(!geometry.center) { geometry = event.content; } geometry.center(); var material = new THREE.MeshPhongMaterial( { ambient: 0xFFFFCC, color: 0xFFFFCC, specular: 0x111111, shininess: 200, side: THREE.DoubleSide } ); var mesh = new THREE.Mesh( geometry, material ); var boundingBox = mesh.geometry.boundingBox.clone(); var s = 3/Math.abs(boundingBox.max.x); mesh.position.set( 0, 0, 0 ); mesh.scale.set( 0.25* s, 0.25 * s, 0.25 *s); mesh.castShadow = false; mesh.receiveShadow = false; scene.add( mesh ); var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 0.7 ); scene.add( light ); jQuery('#<?php print $vs_progress_id; ?> div').html("Loaded model"); setTimeout(function() { jQuery('#<?php print $vs_progress_id; ?> ').fadeOut(500); }, 3000); } function loadProgressMonitor( event ) { jQuery('#<?php print $vs_progress_id; ?> ').show(); var msg = "Loaded " + caUI.utils.formatFilesize(event.loaded/5.2, true); if(total_filesize > 0) { msg += " (" + Math.ceil((event.loaded/total_filesize) * 100) + "%)"; } jQuery('#<?php print $vs_progress_id; ?> div').html(msg); } if (loader.addEventListener) { loader.addEventListener( 'load', postLoad); loader.addEventListener( 'progress', loadProgressMonitor); } loader.load( '<?php print $ps_url; ?> ' , postLoad, loadProgressMonitor); // Lights scene.add( new THREE.AmbientLight( 0x777777 ) ); // renderer if (Detector.webgl) { renderer = new THREE.WebGLRenderer( { antialias: true, alpha: false } ); } else { renderer = new THREE.CanvasRenderer( { antialias: false, alpha: false } ); } renderer.setSize( window.innerWidth, window.innerHeight ); renderer.gammaInput = true; renderer.gammaOutput = true; renderer.physicallyBasedShading = true; renderer.shadowMapEnabled = true; renderer.shadowMapCullFace = THREE.CullFaceBack; controls = new THREE.TrackballControls( camera, renderer.domElement ); controls.rotateSpeed = 0.5; controls.zoomSpeed = 0.5; controls.panSpeed = 0.2; controls.noZoom = false; controls.noPan = false; controls.staticMoving = false; controls.dynamicDampingFactor = 0.3; controls.minDistance = 1.5; controls.maxDistance = 100; renderer.setClearColor( 0x<?php print $vs_bgcolor; ?> , 1 ); controls.keys = [ 16, 17, 18 ]; // [ rotateKey, zoomKey, panKey ] container.appendChild( renderer.domElement ); window.addEventListener( 'resize', onWindowResize, false ); } function addShadowedLight( x, y, z, color, intensity ) { var directionalLight = new THREE.DirectionalLight( color, intensity ); directionalLight.position.set( x, y, z ) scene.add( directionalLight ); directionalLight.castShadow = true; directionalLight.shadowCameraVisible = false; var d = 1; directionalLight.shadowCameraLeft = -d; directionalLight.shadowCameraRight = d; directionalLight.shadowCameraTop = d; directionalLight.shadowCameraBottom = -d; directionalLight.shadowCameraNear = 1; directionalLight.shadowCameraFar = 4; directionalLight.shadowMapWidth = 1024; directionalLight.shadowMapHeight = 1024; directionalLight.shadowBias = -0.005; directionalLight.shadowDarkness = 0.15; return directionalLight; } function onWindowResize() { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize( window.innerWidth, window.innerHeight ); } function animate() { requestAnimationFrame( animate ); render(); } function render() { controls.update(); camera.lookAt( cameraTarget ); renderer.render( scene, camera ); } </script> <?php return ob_get_clean(); } else { return caGetDefaultMediaIconTag(__CA_MEDIA_3D_DEFAULT_ICON__, $vn_width, $vn_height); } }
public function getMediaTag($ps_data, $ps_version, $pa_options = null) { if (!($va_media_info = $this->getMediaArray($ps_data))) { return false; } if (!is_array($pa_options)) { $pa_options = array(); } if (!isset($pa_options["page"]) || $pa_options["page"] < 1) { $pa_options["page"] = 1; } # # Use icon # if (isset($va_media_info[$ps_version]['USE_ICON']) && ($vs_icon_code = $va_media_info[$ps_version]['USE_ICON'])) { return caGetDefaultMediaIconTag($vs_icon_code, $va_media_info[$ps_version]['WIDTH'], $va_media_info[$ps_version]['HEIGHT']); } # # Is this version queued for processing? # if (isset($va_media_info[$ps_version]["QUEUED"]) && $va_media_info[$ps_version]["QUEUED"]) { return $va_media_info[$ps_version]["QUEUED_MESSAGE"]; } $vs_url = $this->getMediaUrl($va_media_info, $ps_version, $pa_options["page"], $pa_options); $o_media = new Media(); $o_vol = new MediaVolumes(); $va_volume = $o_vol->getVolumeInformation($va_media_info[$ps_version]['VOLUME']); $va_properties = $va_media_info[$ps_version]["PROPERTIES"]; if (isset($pa_options['width'])) { $va_properties['width'] = $pa_options['width']; } if (isset($pa_options['height'])) { $va_properties['height'] = $pa_options['height']; } return $o_media->htmlTag($va_media_info[$ps_version]["MIMETYPE"], $vs_url, $va_properties, $pa_options, $va_volume); }
public function getMediaTag($ps_data, $ps_version, $pa_options = null) { if (!($va_media_info = $this->getMediaArray($ps_data))) { return false; } if (!is_array($pa_options)) { $pa_options = array(); } if (!isset($pa_options["page"]) || $pa_options["page"] < 1) { $pa_options["page"] = 1; } # # Use icon # if (isset($va_media_info[$ps_version]['USE_ICON']) && ($vs_icon_code = $va_media_info[$ps_version]['USE_ICON'])) { return caGetDefaultMediaIconTag($vs_icon_code, $va_media_info[$ps_version]['WIDTH'], $va_media_info[$ps_version]['HEIGHT']); } # # Is this version queued for processing? # if (isset($va_media_info[$ps_version]["QUEUED"]) && $va_media_info[$ps_version]["QUEUED"]) { return $va_media_info[$ps_version]["QUEUED_MESSAGE"]; } $vs_url = $this->getMediaUrl($va_media_info, $ps_version, $pa_options["page"], $pa_options); $o_media = new Media(); $o_vol = new MediaVolumes(); $va_volume = $o_vol->getVolumeInformation($va_media_info[$ps_version]['VOLUME']); $va_properties = $va_media_info[$ps_version]["PROPERTIES"]; if (isset($pa_options['width'])) { $va_properties['width'] = $pa_options['width']; } if (isset($pa_options['height'])) { $va_properties['height'] = $pa_options['height']; } $o_config = Configuration::load(); if ($o_config->get('use_pdfjs_viewer')) { foreach ($va_media_info as $vs_version => $va_info) { if (isset($va_info['MIMETYPE']) && $va_info['MIMETYPE'] == 'application/pdf') { JavascriptLoadManager::register("pdfjs"); } } } return $o_media->htmlTag($va_media_info[$ps_version]["MIMETYPE"], $vs_url, $va_properties, $pa_options, $va_volume); }
public function htmlTag($ps_url, $pa_properties, $pa_options = null, $pa_volume_info = null) { JavascriptLoadManager::register('3dmodels'); if (!is_array($pa_options)) { $pa_options = array(); } $vn_width = $pa_options["viewer_width"] ? $pa_options["viewer_width"] : 820; $vn_height = $pa_options["viewer_height"] ? $pa_options["viewer_height"] : 520; $vs_id = $pa_options["id"] ? $pa_options["id"] : "mesh_canvas"; if (in_array($pa_properties['mimetype'], array("application/stl"))) { ob_start(); ?> <canvas id="<?php print $vs_id; ?> " style="border: 1px solid;" width="<?php print $vn_width; ?> " height="<?php print $vn_height; ?> " ></canvas> <script type="text/javascript"> var canvas = document.getElementById('<?php print $vs_id; ?> '); var viewer = new JSC3D.Viewer(canvas); viewer.setParameter('SceneUrl', '<?php print $ps_url; ?> '); viewer.setParameter('RenderMode', 'flat'); viewer.init(); viewer.update(); </script> <?php return ob_get_clean(); } else { return caGetDefaultMediaIconTag(__CA_MEDIA_3D_DEFAULT_ICON__, $vn_width, $vn_height); } }