Skip to content

Commit fd8895a

Browse files
Merge branch 'master' into fix_collections
2 parents 6a291df + 254a69f commit fd8895a

File tree

2 files changed

+83
-20
lines changed

2 files changed

+83
-20
lines changed

Resources/Public/Javascript/3DViewer/main.js

Lines changed: 81 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ import Stats from './js/jsm/libs/stats.module.js';
2424

2525
import { OrbitControls } from './js/jsm/controls/OrbitControls.js';
2626
import { TransformControls } from './js/jsm/controls/TransformControls.js';
27+
// BEGIN - path can't be changed while updating
2728
import { GUI } from './node_modules/lil-gui/dist/lil-gui.esm.min.js';
29+
// END - path can't be changed while updating
2830
import { FBXLoader } from './js/jsm/loaders/FBXLoader.js';
2931
import { DDSLoader } from './js/jsm/loaders/DDSLoader.js';
3032
import { MTLLoader } from './js/jsm/loaders/MTLLoader.js';
@@ -52,7 +54,7 @@ const CONFIG = {
5254
"galleryImageClass": "field--type-image"
5355
};
5456

55-
let camera, scene, renderer, stats, controls, loader, ambientLight, dirLight, dirLightTarget;
57+
let camera, scene, renderer, stats, controls, loader, ambientLight, dirLight, dirLightTarget, cameraLight, cameraLightTarget;
5658
let imported;
5759
var mainObject = [];
5860
var metadataContentTech;
@@ -70,6 +72,7 @@ const container = document.getElementById(CONFIG.container);
7072
container.setAttribute("width", window.self.innerWidth);
7173
container.setAttribute("height", window.self.innerHeight);
7274
container.setAttribute("display", "flex");
75+
// BEGIN - part necessary to keep while updating
7376
const model = container.getAttribute("model");
7477
const xmlPath = container.getAttribute("xml");
7578
const settingsPath= container.getAttribute("settings");
@@ -82,6 +85,7 @@ if (dfgViewer) {
8285
wisskiID = parseInt(elementsURL[1]);
8386
}
8487
} else {
88+
// END - part necessary to keep while updating
8589
elementsURL = window.location.pathname;
8690
elementsURL = elementsURL.match("/wisski/navigate/(.*)/view");
8791
wisskiID = elementsURL[1];
@@ -91,7 +95,9 @@ var filename = container.getAttribute("3d").split("/").pop();
9195
var basename = filename.substring(0, filename.lastIndexOf('.'));
9296
var extension = filename.substring(filename.lastIndexOf('.') + 1);
9397
var path = container.getAttribute("3d").substring(0, container.getAttribute("3d").lastIndexOf(filename));
98+
// BEGIN - part necessary to keep while updating
9499
var fileSize;
100+
// END - part necessary to keep while updating
95101
const uri = path.replace(CONFIG.domain+"/", "");
96102
const EXPORT_PATH = '/export_xml_single/';
97103
const loadedFile = basename + "." + extension;
@@ -128,9 +134,11 @@ container.appendChild(statsContainer);
128134
var guiContainer = document.createElement("div");
129135
guiContainer.id = 'guiContainer';
130136
guiContainer.className = 'guiContainer';
137+
// BEGIN - part necessary to keep while updating
131138
guiContainer.style.position = 'absolute';
132139
guiContainer.style.right = '2%';
133140
guiContainer.style.marginTop = '0px';
141+
// END - part necessary to keep while updating
134142
var guiElement = document.createElement("div");
135143
guiElement.id = 'guiElement';
136144
guiElement.className = 'guiElement';
@@ -254,6 +262,19 @@ function readWissKI () {
254262
xmlhttp.send();
255263
}
256264

265+
function readMetadataFromFile(responseText) {
266+
const parser = new DOMParser();
267+
const doc = parser.parseFromString(responseText, "application/xml");
268+
var data;
269+
for (let childNode of doc.documentElement.childNodes) {
270+
data = childNode.childNodes;
271+
if (typeof (data) !== undefined && data.length > 0) {
272+
break;
273+
}
274+
}
275+
return data;
276+
}
277+
257278
//readWissKI();
258279

259280
function createClippingPlaneGroup( geometry, plane, renderOrder ) {
@@ -308,8 +329,9 @@ function addTextWatermark (_text, _scale) {
308329
new THREE.MeshStandardMaterial( { color: 0xffffff, flatShading: true, side: THREE.DoubleSide, depthTest: false, depthWrite: false, transparent: true, opacity: 0.4 } ) // side
309330
];
310331
const loader = new FontLoader();
311-
332+
// BEGIN - path can't be changed while updating
312333
loader.load( '/typo3conf/ext/dlf/Resources/Public/JavaScript/3DViewer/fonts/helvetiker_regular.typeface.json', function ( font ) {
334+
// END - path can't be changed while updating
313335

314336
const textGeo = new TextGeometry( _text, {
315337
font,
@@ -346,8 +368,9 @@ function addTextPoint (_text, _scale, _point) {
346368
new THREE.MeshStandardMaterial( { color: 0x0000ff, flatShading: true, side: THREE.DoubleSide, depthTest: false, depthWrite: false, transparent: true, opacity: 0.4 } ) // side
347369
];
348370
const loader = new FontLoader();
349-
371+
// BEGIN - path can't be changed while updating
350372
loader.load( '/typo3conf/ext/dlf/Resources/Public/JavaScript/3DViewer/fonts/helvetiker_regular.typeface.json', function ( font ) {
373+
// END - path can't be changed while updating
351374

352375
const textGeo = new TextGeometry( _text, {
353376
font,
@@ -486,6 +509,8 @@ function setupObject (_object, _camera, _light, _data, _controls) {
486509
}
487510
}
488511
}
512+
cameraLightTarget.position.set(_object.position.x, _object.position.y, _object.position.z);
513+
cameraLight.target.updateMatrixWorld();
489514
}
490515

491516
function setupClippingPlanes (_geometry, _size, _distance) {
@@ -851,6 +876,7 @@ function buildRuler(_id) {
851876
}
852877

853878
function onWindowResize() {
879+
// BEGIN - values can't be changed while updating
854880
var rightOffsetDownload = -74;
855881
var rightOffsetEntity = -77;
856882
var rightOffsetFullscreen = 1;
@@ -883,6 +909,7 @@ function onWindowResize() {
883909
viewEntity.setAttribute('style', 'right: ' + rightOffsetEntity +'%');
884910

885911
fullscreenMode.setAttribute('style', 'bottom:' + Math.round(-canvasDimensions.y + 55) + 'px');
912+
// END - values can't be changed while updating
886913
controls.update();
887914
render();
888915
}
@@ -1082,20 +1109,20 @@ function fetchSettings ( path, basename, filename, object, camera, light, contro
10821109
metadataContentTech += 'Vertices: <b>' + metadata['vertices'] + '</b><br>';
10831110
metadataContentTech += 'Faces: <b>' + metadata['faces'] + '</b><br>';
10841111

1112+
// BEGIN - part necessary to keep while updating
10851113
var metadataPath = CONFIG.metadataDomain + EXPORT_PATH + wisskiID + '?page=0&amp;_format=xml';
10861114
if (proxy) {
10871115
metadataPath = xmlPath;
10881116
}
1117+
// END - part necessary to keep while updating
10891118

10901119
var req = new XMLHttpRequest();
10911120
req.responseType = 'xml';
10921121
req.open('GET', metadataPath, true);
10931122
req.onreadystatechange = function (aEvt) {
10941123
if (req.readyState === 4) {
10951124
if(req.status === 200) {
1096-
const parser = new DOMParser();
1097-
const doc = parser.parseFromString(req.responseText, "application/xml");
1098-
var data = doc.documentElement.childNodes[0].childNodes;
1125+
var data = readMetadataFromFile(req.responseText);
10991126
if (typeof (data) !== undefined) {
11001127
for(var i = 0; i < data.length; i++) {
11011128
var fetchedValue = addWissKIMetadata(data[i].tagName, data[i].textContent);
@@ -1126,8 +1153,12 @@ function fetchSettings ( path, basename, filename, object, camera, light, contro
11261153
metadataContainer.appendChild( viewEntity );
11271154
fullscreenMode = document.createElement('div');
11281155
fullscreenMode.setAttribute('id', 'fullscreenMode');
1156+
// BEGIN - values can't be changed while updating
11291157
fullscreenMode.setAttribute('style', 'bottom:' + Math.round(-canvasDimensions.y + 85) + 'px');
1158+
// END - values can't be changed while updating
1159+
// BEGIN - path can't be changed while updating
11301160
fullscreenMode.innerHTML = "<img src='/typo3conf/ext/dlf/Resources/Public/JavaScript/3DViewer/img/fullscreen.png' alt='Fullscreen' width=20 height=20 title='Fullscreen mode'/>";
1161+
// END - path can't be changed while updating
11311162
metadataContainer.appendChild(fullscreenMode);
11321163
//var _container = document.getElementById("MainCanvas");
11331164
container.appendChild(metadataContainer);
@@ -1161,6 +1192,7 @@ const onError = function (_event) {
11611192
};
11621193

11631194
const onProgress = function ( xhr ) {
1195+
// BEGIN - part necessary to keep while updating
11641196
var percentComplete;
11651197
if (xhr.lengthComputable) {
11661198
percentComplete = xhr.loaded / xhr.total * 100;
@@ -1181,14 +1213,15 @@ const onProgress = function ( xhr ) {
11811213
showToast("Model has been loaded.");
11821214
}
11831215
}
1216+
// END - part necessary to keep while updating
11841217
};
11851218

11861219
function loadModel ( path, basename, filename, extension, orgExtension ) {
11871220
if (!imported) {
11881221
circle.show();
11891222
circle.set(0, 100);
11901223
var modelPath = path + filename;
1191-
1224+
// BEGIN - part necessary to keep while updating
11921225
if (proxy) {
11931226
modelPath = model;
11941227
}
@@ -1201,6 +1234,7 @@ function loadModel ( path, basename, filename, extension, orgExtension ) {
12011234
}
12021235
};
12031236
req.send(null);
1237+
// END - part necessary to keep while updating
12041238

12051239
switch(extension.toLowerCase()) {
12061240
case 'obj':
@@ -1271,7 +1305,9 @@ function loadModel ( path, basename, filename, extension, orgExtension ) {
12711305

12721306
case 'ifc':
12731307
const ifcLoader = new IFCLoader();
1308+
// BEGIN - path can't be changed while updating
12741309
ifcLoader.ifcManager.setWasmPath( '/typo3conf/ext/dlf/Resources/Public/JavaScript/3DViewer/js/jsm/loaders/ifc/' );
1310+
// END - path can't be changed while updating
12751311
ifcLoader.load( modelPath, function ( object ) {
12761312
//object.position.set (0, 300, 0);
12771313
scene.add( object );
@@ -1334,11 +1370,13 @@ function loadModel ( path, basename, filename, extension, orgExtension ) {
13341370
case '3ds':
13351371
loader = new TDSLoader( );
13361372
loader.setResourcePath( path );
1373+
// BEGIN - part necessary to keep while updating
13371374
modelPath = path + basename + "." + extension;
13381375
if (proxy) {
13391376
modelPath = model;
13401377
}
13411378
loader.load( modelPath, function ( object ) {
1379+
// END - part necessary to keep while updating
13421380
object.traverse( function ( child ) {
13431381
if ( child.isMesh ) {
13441382
//child.material.specular.setScalar( 0.1 );
@@ -1362,7 +1400,9 @@ function loadModel ( path, basename, filename, extension, orgExtension ) {
13621400
case 'glb':
13631401
case 'gltf':
13641402
const dracoLoader = new DRACOLoader();
1403+
// BEGIN - path can't be changed while updating
13651404
dracoLoader.setDecoderPath( '/typo3conf/ext/dlf/Resources/Public/JavaScript/3DViewer/js/libs/draco/' );
1405+
// END - path can't be changed while updating
13661406
dracoLoader.preload();
13671407
const gltf = new GLTFLoader();
13681408
gltf.setDRACOLoader(dracoLoader);
@@ -1390,6 +1430,7 @@ function loadModel ( path, basename, filename, extension, orgExtension ) {
13901430
scene.add( gltf.scene );
13911431
},
13921432
function ( xhr ) {
1433+
// BEGIN - part necessary to keep while updating
13931434
var percentComplete;
13941435
if (xhr.lengthComputable) {
13951436
percentComplete = xhr.loaded / xhr.total * 100;
@@ -1409,6 +1450,7 @@ function loadModel ( path, basename, filename, extension, orgExtension ) {
14091450
showToast("Model " + filename + " has been loaded.");
14101451
}
14111452
}
1453+
// END - part necessary to keep while updating
14121454
}/*,
14131455
function ( ) {
14141456
showToast("GLTF or file with given name (possible archive/filename mismatch) representation not found, trying original file [semi-automatic]...");
@@ -1523,6 +1565,11 @@ function onPointerUp( e ) {
15231565
function onPointerMove( e ) {
15241566
pointer.x = ((e.clientX - container.getBoundingClientRect().left)/ renderer.domElement.clientWidth) * 2 - 1;
15251567
pointer.y = - ((e.clientY - container.getBoundingClientRect().top) / renderer.domElement.clientHeight) * 2 + 1;
1568+
if (e.buttons === 1) {
1569+
if (pointer.x !== onDownPosition.x && pointer.y !== onDownPosition.y) {
1570+
cameraLight.position.set(camera.position.x, camera.position.y, camera.position.z);
1571+
}
1572+
}
15261573
if (e.buttons !== 1) {
15271574
if (EDITOR) {
15281575
raycaster.setFromCamera( pointer, camera );
@@ -1623,7 +1670,9 @@ function mainLoadModel (_ext) {
16231670
function init() {
16241671
// model
16251672
//canvasDimensions = {x: container.getBoundingClientRect().width, y: container.getBoundingClientRect().bottom};
1673+
// BEGIN - values can't be changed while updating
16261674
canvasDimensions = {x: window.self.innerWidth*0.8, y: window.self.innerHeight};
1675+
// END - values can't be changed while updating
16271676
container.setAttribute("width", canvasDimensions.x);
16281677
container.setAttribute("height", canvasDimensions.y);
16291678

@@ -1653,6 +1702,18 @@ function init() {
16531702
dirLight.shadow.mapSize.height = 1024*4;
16541703
scene.add( dirLight );
16551704
lightObjects.push( dirLight );
1705+
1706+
cameraLightTarget = new THREE.Object3D();
1707+
cameraLightTarget.position.set(camera.position.x, camera.position.y, camera.position.z);
1708+
scene.add(cameraLightTarget);
1709+
1710+
cameraLight = new THREE.DirectionalLight( 0xffffff );
1711+
cameraLight.position.set( camera.position );
1712+
cameraLight.castShadow = false;
1713+
cameraLight.intensity = 0.3;
1714+
scene.add( cameraLight );
1715+
cameraLight.target = cameraLightTarget;
1716+
cameraLight.target.updateMatrixWorld();
16561717

16571718
renderer = new THREE.WebGLRenderer( { antialias: true, logarithmicDepthBuffer: true, colorManagement: true, sortObjects: true, preserveDrawingBuffer: true, powerPreference: "high-performance" } );
16581719
renderer.setPixelRatio( window.devicePixelRatio );
@@ -1710,44 +1771,46 @@ function init() {
17101771

17111772
var _ext = extension.toLowerCase();
17121773

1774+
// BEGIN - part necessary to keep while updating
17131775
var metadataPath = CONFIG.metadataDomain + EXPORT_PATH + wisskiID + '?page=0&amp;_format=xml';
17141776
if (proxy) {
17151777
metadataPath = xmlPath;
17161778
}
1779+
// END - part necessary to keep while updating
17171780

17181781
var req = new XMLHttpRequest();
17191782
req.responseType = 'xml';
17201783
req.open('GET', metadataPath, true);
17211784
req.onreadystatechange = function (aEvt) {
17221785
if (req.readyState === 4) {
17231786
if(req.status === 200) {
1724-
const parser = new DOMParser();
1725-
const doc = parser.parseFromString(req.responseText, "application/xml");
1726-
var data = doc.documentElement.childNodes[0].childNodes;
1787+
var data = readMetadataFromFile(req.responseText);
17271788
if (typeof (data) !== undefined) {
17281789
var _found = false;
17291790
for(var i = 0; i < data.length && !_found; i++) {
17301791
if ((typeof (data[i].tagName) !== "undefined") && (typeof (data[i].textContent) !== "undefined")) {
17311792
var _label = data[i].tagName.replace("wisski_path_3d_model__", "");
17321793
if (typeof(_label) !== "undefined" && _label === "converted_file_name") {
17331794
_found = true;
1734-
var _autoPath = data[i].textContent;
1735-
//check wheter semo-automatic path found
1795+
var _autoPath = data[i].textContent.trim();
1796+
//check whether semi-automatic path found
17361797
if (_autoPath !== '') {
1737-
filename = _autoPath.split("/").pop();
1738-
basename = filename.substring(0, filename.lastIndexOf('.'));
1739-
extension = filename.substring(filename.lastIndexOf('.') + 1);
1740-
_ext = extension.toLowerCase();
1741-
path = _autoPath.substring(0, _autoPath.lastIndexOf(filename));
1798+
filename = _autoPath.split("/").pop().trim();
1799+
basename = filename.substring(0, filename.lastIndexOf('.')).trim();
1800+
extension = filename.substring(filename.lastIndexOf('.') + 1).trim();
1801+
_ext = extension.toLowerCase().trim();
1802+
path = _autoPath.substring(0, _autoPath.lastIndexOf(filename)).trim();
17421803
}
17431804
mainLoadModel(_ext);
17441805
}
17451806
}
17461807
}
1808+
} else {
1809+
showToast("Error during loading metadata content - empty metadata file\n");
17471810
}
17481811
}
17491812
else {
1750-
showToast("Error during loading metadata content");
1813+
showToast("Error during loading metadata content\n");
17511814
mainLoadModel (_ext);
17521815
}
17531816
}

Tests/Functional/Common/SolrIndexingTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ public function canSearchInCollections()
133133
$collections = $this->collectionRepository->findCollectionsBySettings([
134134
'index_name' => ['Musik', 'Projekt: Dresdner Hefte'],
135135
]);
136-
$musik = $collections[0];
137-
$dresdnerHefte = $collections[1];
136+
$musik[] = $collections[0];
137+
$dresdnerHefte[] = $collections[1];
138138

139139
$settings = [
140140
'solrcore' => $core->solr->core,

0 commit comments

Comments
 (0)