* Process resources that are needed right away.
(
taskIdentifier: string,
onProgress?: (count: number, total: number) => Promise<void>
)
| 1138 | * Process resources that are needed right away. |
| 1139 | */ |
| 1140 | async processResources( |
| 1141 | taskIdentifier: string, |
| 1142 | onProgress?: (count: number, total: number) => Promise<void> |
| 1143 | ): Promise<void> { |
| 1144 | const loadingState = this.loadingStates.get(taskIdentifier); |
| 1145 | if (!loadingState) { |
| 1146 | logger.warn( |
| 1147 | `Can\'t load resource for unknown ${this.name}: "${taskIdentifier}".` |
| 1148 | ); |
| 1149 | return; |
| 1150 | } |
| 1151 | if (loadingState.status !== 'loaded') { |
| 1152 | logger.warn( |
| 1153 | `Resources are not loaded can\'t process them: "${taskIdentifier}".` |
| 1154 | ); |
| 1155 | return; |
| 1156 | } |
| 1157 | |
| 1158 | let parsedCount = 0; |
| 1159 | for (const resourceName of loadingState.resourceNames) { |
| 1160 | const resource = this.resourceLoader._resources.get(resourceName); |
| 1161 | if (!resource) { |
| 1162 | logger.warn('Unable to find resource "' + resourceName + '".'); |
| 1163 | continue; |
| 1164 | } |
| 1165 | await this.resourceLoader._processResource(resource); |
| 1166 | parsedCount++; |
| 1167 | onProgress && |
| 1168 | (await onProgress(parsedCount, loadingState.resourceNames.length)); |
| 1169 | } |
| 1170 | loadingState.status = 'ready'; |
| 1171 | } |
| 1172 | |
| 1173 | /** |
| 1174 | * Put a given scene at the end of the queue. |
no test coverage detected